0

私のスキーマは次のようになります。

super.js:

var superSchema = new Schema({
  title: {
    type: String,
    default: '',
    trim: true
  },
  item: [{
    type: Schema.ObjectId,
    ref: 'Item'
  }]
});

item.js:

var itemSchema = new Schema({
  name: {
    type: String,
    default: '',
    trim: true
  }
});

私のjsonは次のようになります。

[{
    "title": "Team 1",
    "items": [
      "52c23f2129sdf1720d000006",
      "52c23f2129asd1720d000006",
      "52c23f212992cfdsd00000f6"]
},{
    "title": "Team 2",
    "items": [
      "52c23f2129sdf1720d000006",
      "52c23f2129asd1720d000006",
      "52c23f212992cfdsd00000f6"]
}]

次に、item[0].nameこのようにlist.htmlファイルにアクセスしようとしましたが、{{item[0].name}}何も返されず、item [0]がIDを返します。

angular htmlファイルのitem [0] .nameにアクセスするにはどうすればよいですか?

私のsuperDuperController.js :

$scope.find = function() {
    SuperDuper.query(function(superDuper) {
        $scope.superDuper = superDuper;
    });
};
4

1 に答える 1

2

クライアント側に応答を送信する前に、アイテムを入力する必要があります。

Super.find({_id: super_id}).populate('item').exec(function(err, super) {
    if(err) {

    }
    else {
    // Populated the items
    // Send the **super** in response
    }

})

{{item[0].name}}これで、クライアント側でアクセスできます。

于 2013-12-31T05:12:19.517 に答える