Ember.js Ember对象,具有嵌套数组
为了学习余烬,我一直在尝试制作一个计算时区的简单应用程序 当一个人进入他们的城市和另一个人的城市时,我向我的API发出GET请求,该请求返回如下日期-- 在车把上,我有Ember.js Ember对象,具有嵌套数组,ember.js,Ember.js,为了学习余烬,我一直在尝试制作一个计算时区的简单应用程序 当一个人进入他们的城市和另一个人的城市时,我向我的API发出GET请求,该请求返回如下日期-- 在车把上,我有 <div class="container"> <div class="col-md-6 col-md-offset-3"> <header> <h2>We found <span class="twenty-four-header">{{tot
<div class="container">
<div class="col-md-6 col-md-offset-3">
<header>
<h2>We found <span class="twenty-four-header">{{totalTimes}}</span>
great meeting {{pluralize totalTimes 'time' 'times'}} for you!</h2>
</header>
<div class="main-content">
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{view RightTime.AutoCompleteAddressView value=myCity placeholder="What's your city?"
class="form-control input-lg" latLng=myLatLng}}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{view RightTime.AutoCompleteAddressView value=theirCity placeholder="What their city?"
class="form-control input-lg" latLng=theirLatLng}}
</div>
</div>
</div>
{{#each meetingTime in greatTimes}}
{{render 'meetingTime' meetingTime }}
{{/each}}
</div><!--main-content-->
</div>
</div>
我觉得问题在于
.done(function(response){
meeting.set('meetingTimes', Ember.A(response));
});
我正在重置整个meetingtimes数组,这可能是错误的做法
你将如何使meetingTimes arrray更新并反映在车把中?我可能只会将
great_times
移动到一个计算属性中,该属性取决于meetingTimes
,并且没有链接
差不多
greatTimes: function() {
return Em.get(this, 'meetingTimes.great_times') || [];
}.property('meetingTimes'),
用这样的模板
{{#each meetingTime in greatTimes}}
{{render 'meetingTime' meetingTime }}
{{/each}}
嘿,主销,我添加了这个更新,但在某些情况下似乎仍然不起作用。当我尝试多伦多和纽约时,我得到12分。然后,当我把它改为大阪时,我应该只得到1,但取而代之的是,1被附加到每个循环中。你可以看看这里->你介意分享你的模板吗?如果我猜的话,我会说你的模板有问题(比如不匹配的标签,或者无效的html)。Hi-kingpin,当然,会在这里更新代码片段。应用程序的完整github就在这里——哦,天哪,你说得对!这是meetingTime.Handlebar模板的结束div标记。金品先生,非常感谢!太棒了,很高兴听到你找到了。
greatTimes: function() {
return Em.get(this, 'meetingTimes.great_times') || [];
}.property('meetingTimes'),
{{#each meetingTime in greatTimes}}
{{render 'meetingTime' meetingTime }}
{{/each}}