我可以做{{unbound title}}或者
{{#each file}}
{{unbound filename}}
{{/each}}在模型上。
但是,在ember中所有的对象对我来说都是有问题的。下面的方法都不起作用
{{unbound location.address}}和
{{with location}}
{{unbound address}}
{{/with}}这两种方法都会导致空输出
发布于 2014-07-31 19:56:24
在处理您的模型时,任何belongsTo关系都尚未解析。因为您没有绑定,所以一旦数据可用,它也不能回溯更新。我昨天找到了这个变通方法,帮助我解决了我与belongsTo的(类似)问题:https://github.com/emberjs/data/issues/1405
对于现有记录,您需要在路由中执行类似以下操作:
// your-route beforeModel: function() { var self = this; return
Em.RSVP.hash({
firstBelongsTo: this.store.find('first-belongs-to'),
secondBelongsTo: this.store.find('second-belongs-to')
}).then(function (models) {
self.controllerFor('this-route').setProperties(models); });Ember和你的控制器中,确保在设置属性之前声明它们,因为
试图在内容不存在的时候抛出它们:
// your-controller App.MyController = Ember.Controller.extend({
firstBelongsTo: null, secondBelongsTo: null });通过在beforeModel钩子中返回promise,您将告诉路由在加载模型之前解析promise,这也意味着在任何呈现发生之前。这使您的应用程序有时间在将数据绑定到选择框之前预先加载数据。
https://stackoverflow.com/questions/25051833
复制相似问题