0

I can't seem to figure out what I'm doing wrong here. I'd like to drill down into the JSON array below to display data from within the months array.

My schema:

var mongoose  = require('mongoose');
var Schema    = mongoose.Schema;

var CalendarSchema   = new Schema({

August: [
  {
    day: String,
    title: String,
    summary: String,
    description: String
  }
      ]
});

var Calendar = mongoose.model('CalendarData', CalendarSchema);



Calendar.find({}).exec(function(err, collection){
  if(collection.length === 0){
  Calendar.create({
'August': [
    {
      'day':'21', 
      'title':'cal title', 
      'summary': 'calsummary', 
      'decription': 'cal desc'
    }
          ]
    });
  }
});


module.exports = mongoose.model('CalendarData',  CalendarSchema);

my angular controller

 $scope.calendar = [];

 CAL.API.query(function(results) {
        $scope.calendar = results;
    }); 

My view

<div class="events" ng-repeat="cal in calendar.August">
   <h5>{{cal.title}}</h5>
</div>

JSON object coming through to controller

[
  -{
    _id: "53cfb6616ba190954d7682aa"
    __v: 0
    -August: [
         -{
          day: "21"
          title: "cal title"
          summary: "calsummary"
          _id: "53cfb6616ba190954d7682ab"
          }
            ]
    }
]
1
  • "August" is an array. Also since your problem is clearly on the angular side please don't post all tags in the stack you are using. Commented Jul 23, 2014 at 14:00

1 Answer 1

2

August is an array inside of an array You should iterate over it in ng-repeat...

<div class="events" ng-repeat="event in calendar[0].August">
   <h5>{{event.title}}</h5>
</div>
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry missed the outer array.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.