我有以下内容:
模板
{{#each item in controller.pagedAutomationExceptions}}
{{log item}}
<tr {{bindAttr class="item.rowClass"}}>
<td class="text-center">{{unbound item.BTicket}}</td>
<td>{{unbound item.Reason}}</td>
<td>{{unbound item.TimeReceived}}</td>
<td>
{{#if item.ShowContactVoltageSources}}
{{view Ember.Select
contentBinding="controller.contactVoltageSources"
optionValuePath="content.Name"
optionLabelPath="content.Name"
valueBinding="item.AutomationValue"
prompt="Choose one..."}}
{{/if}}
{{#if item.ShowVoltageField}}
{{view Ember.TextField valueBinding="item.AutomationValue"}}
{{/if}}
{{#if item.ShowEnergizedObjects}}
{{view Ember.Select
contentBinding="controller.energizedObjects"
optionValuePath="content.Name"
optionLabelPath="content.Name"
valueBinding="item.AutomationValue"
prompt="Choose one..."}}
{{/if}}
</td>
<td>
{{#if item.Errored}}
{{/if}}
{{#if item.IsUpdating}}
<btn class="btn btn-primary" disabled="disabled">
Updating..
</btn>
{{else}}
<btn {{action updateAutomationException item target="controller"}}
class="btn btn-primary">
Update
</btn>
{{/if}}
</td>
</tr>
{{/each}}
控制器
(对不起,如果它不准确,我是从记忆中做的,我改变了它试图解决问题)
App.Exception = Ember.Object.extend({
// properties used in template, etc..
});
App.ExceptionsController = Ember.Controller.extend({
init: function () {
this._super();
// ajax request to get exceptions from database
// once inspections are loaded
// set(automationExceptions, response)
// loadMoreExceptions()
},
automationExceptions: [],
pagedAutomationExceptions: Ember.A(),
loadMoreExceptions: function () {
// i have a variable that i store to tell me
// how many exceptions I'm currently showing.
// If there are more, I just add to this variable
// the paging amount, and for those elements
// create a new exception and add it to the
// paged array. This method also seems to work
// because I get more records on the view.
for (; currentTake < newTake; ++currentTake) {
var simple = automationExceptions[currentTake];
this.get('pagedAutomationExceptions').pushObject(
App.Exception.create(simple));
}
},
updateAutomationException: function () {
// ajax post update, this works fine..
}
});
当我尝试更改路线时,出现以下错误:
未捕获的类型错误:无法读取未定义的属性“IsUpdating”
如果我删除该行,那么还有一些其他属性无法读取。
我不确定发生了什么,显然 Ember 以某种方式获取了一个未定义的对象,但我不知道如何。我实例化所有对象并将它们推送到数组上。