Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

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"
          }
            ]
    }
]
share|improve this question
    
"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. – Neil Lunn Jul 23 '14 at 14:00
up vote 2 down vote accepted

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>
share|improve this answer
    
That also does not work for some reason... – byrdr Jul 23 '14 at 14:05
    
Sorry missed the outer array. – Anthony Chu Jul 23 '14 at 14:09
    
Great, thanks! That makes sense. – byrdr Jul 23 '14 at 14:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.