我有三个相互关联的模型。关系如下:
App.Lodge = DS.Model.extend({
name: DS.attr('string'),
address: DS.attr('string'),
website: DS.attr('string'),
phone: DS.attr('string'),
uniqueDescription: DS.attr('string'),
basicDescription: DS.attr('string'),
yearOpened: DS.attr('string'),
propertySize: DS.attr('string'),
propertyType: DS.attr('string'),
languages: DS.attr('string'),
owner: DS.attr('string'),
uniqueQualifier1: DS.attr('string'),
uniqueQualifier2: DS.attr('string'),
uniqueQualifier3: DS.attr('string'),
uniqueQualifier4: DS.attr('string'),
lowDayPrice: DS.attr('string'),
highDayPrice: DS.attr('string'),
favoriteBoolean: DS.attr('boolean')
});
App.Favorite = DS.Model.extend({
name: DS.belongsTo('lodge'),
notes: DS.attr('string'),
address: DS.belongsTo('lodge'),
group: DS.belongsTo('group'),
photo: DS.attr('string'),
});
App.Group = DS.Model.extend({
name: DS.attr('string'),
favorites: DS.hasMany('favorite', {async:true})
});
我正在尝试从模板访问模型name
中的属性。模板是:Favorite
Lodge
<script type="text/x-handlebars" data-template-name="group">
<div class="modal fade" id="groupModal">
<div class="modal-dialog groupModal">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title tertiaryHeading">{{name}}</h4>
</div>
<div class="modal-body">
<div class="groupFavoriteContainer" {{bind-attr data-groupID=id}}>
<div class="favoriteControlLinks">
<a class="actionLink favoritesControl"><span class="glyphicon glyphicon-share"></span> Share this Group</a><a class="actionLink favoritesControl"><span class="glyphicon glyphicon-globe"></span> Show this Group on a Map</a><a class="actionLink favoritesControl back backToGroup"><span class="glyphicon glyphicon-arrow-left"></span> Back to My Group</a>
</div>
{{#each favorite in favorites}}
<div class="favoriteContainer">
<div class="favoritesImage">
<span class="favoritesLodgeName"><h3 class="tertiaryHeading">{{favorite.name}}</h3><p class="favoritesAddress">{{favorite.address}}</p><span>
</div>
<a class="actionLink favoriteControl" {{action removeFavorite item}} {{bind-attr data-favoriteid=id}}><span class="glyphicon glyphicon-trash"></span> Remove</a><a class="actionLink favoriteControl"><span class="glyphicon glyphicon-share"></span> Share</a><a class="actionLink favoriteControl"><span class="glyphicon glyphicon-envelope"></span> Contact</a>
<div class="notes">
{{favorite.notes}}
</div>
</div>
{{/each}}
</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</script>
当我执行 {{favorite.name}} 时,它会打印出:<App.Lodge:ember366:1>
。与 {{favorite.address}} 相同
如何访问这些属性?