title: Populate nested object with MongoosJS, NodeJS and AngularJS
body: <p>I have a problem with getting nested objects in a model.
  I have a model restaurant, where i am referencing an article. This is just an demo for me to test how this is working, but i am not getting it.. :(</p>
  
  <p>ah.. i am using meanjs..</p>
  
  <p>here is my restaurant model..</p>
  
  <pre><code>'use strict';
  
  /**
   * Module dependencies.
   */
  var mongoose = require('mongoose'),
      Schema = mongoose.Schema;
  
  /**
   * Restaurant Schema
   */
  var RestaurantSchema = new Schema({
      name: {
          type: String,
          default: '',
          required: 'Please fill Restaurant name',
          trim: true
      },
      desc: {
          type: String,
          default: 'description is here'
      },
      created: {
          type: Date,
          default: Date.now
      },
      user: {
          type: Schema.ObjectId,
          ref: 'User'
      },
      article: {
          type: Schema.ObjectId,
          ref: 'Article'
      }
  });
  
  mongoose.model('Restaurant', RestaurantSchema);
  </code></pre>
  
  <p>This is my Article model. </p>
  
  <pre><code>'use strict';
  
  /**
   * Module dependencies.
   */
  var mongoose = require('mongoose'),
      Schema = mongoose.Schema;
  
  /**
   * Article Schema
   */
  var ArticleSchema = new Schema({
      created: {
          type: Date,
          default: Date.now
      },
      title: {
          type: String,
          default: '',
          trim: true,
          required: 'Title cannot be blank'
      },
      content: {
          type: String,
          default: '',
          trim: true
      }
  });
  
  mongoose.model('Article', ArticleSchema);
  </code></pre>
  
  <p>this two methods are in the nodejs backend restaurant controller:</p>
  
  <pre><code>exports.list = function(req, res) { Restaurant.find().sort('-created').populate('article').exec(function(err, restaurants) {
          if (err) {
              return res.status(400).send({
                  message: errorHandler.getErrorMessage(err)
              });
          } else {
              res.jsonp(restaurants);
          }
      });
  };
  
  exports.restaurantByID = function(req, res, next, id) { Restaurant.findById(id).populate('article').exec(function(err, restaurant) {
          if (err) return next(err);
          if (! restaurant) return next(new Error('Failed to load Restaurant ' + id));
          req.restaurant = restaurant ;
          next();
      });
  };
  </code></pre>
  
  <p>I have then an angular controller method to safe a new restaurant and an article, which is working. When i am accessing <code>"http://localhost:3000/#!/articles"</code>. But when i am trying to get for example the title out, it is not working. </p>
  
  <p>I am creating my restaurant and article this way:</p>
  
  <pre><code>// Create new Restaurant
          $scope.create = function () {
              // Create new Restaurant object
  
              var newArticle = new Articles({
                  title: this.articleTitle
              });
              newArticle.$save();
  
              var restaurant = new Restaurants({
                  name: this.name,
                  desc: this.description,
                  article: newArticle._id
              });
  
              // Redirect after save
              restaurant.$save(function (response) {
                  $location.path('restaurants/' + response._id);
  
                  // Clear form fields
                  $scope.name = '';
              }, function (errorResponse) {
                  $scope.error = errorResponse.data.message;
              });
          };
  </code></pre>
  
  <p>this is in my create view:</p>
  
  <pre><code>&lt;div class="controls"&gt;
                          &lt;input type="text" data-ng-model="name" id="name" class="form-control" placeholder="Name" required&gt;
                          &lt;input type="text" data-ng-model="articleTitle" id="article" class="form-control" placeholder="artikel" required&gt;
                          &lt;input type="text" data-ng-model="description" id="description" class="form-control" placeholder="desription" required&gt;
                      &lt;/div&gt;
  </code></pre>
  
  <p>and this is in my list view</p>
  
  <pre><code>&lt;h4 class="list-group-item-heading" data-ng-bind="restaurant.name"&gt;&lt;/h4&gt;
              &lt;h3 class="list-group-item-heading" data-ng-bind="restaurant.article"&gt;&lt;/h3&gt;
              &lt;h3 class="list-group-item-heading" data-ng-bind="restaurant.desc"&gt;&lt;/h3&gt;
  </code></pre>
  
  <p>the description is visible in the browser, but, nothing visible about the article. How do i get the information about the article in the restaurant object?</p>
  
  <p>Probably, this is very easy, but i did not find it out.. </p>
  
  <p>thanks in advanced.. </p>