我有两个json输入,
输入1:
var status = [{
isLogged : true
}];
输入2:
var posts = [{
id: '1',
datalink:124,
isVoted : true,
votecount : 123,
title: "Rails is Omakase",
author: { name: "d2h" },
date: new Date('12-27-2012'),
excerpt: "There are lots of à la carte software environments in this world. Places where in order to eat, you must first carefully look over the menu of options to order exactly what you want."
}]
当有一个json时,一切正常,
App.Route = Ember.Route.extend({
model : function(){
return posts;
}
});
但是当我添加第二个输入时,它没有工作
App.Route = Ember.Route.extend({
model : function(){
return posts;
},
logged : function(){
return status;
}
});
如何在html中获得第二个输入和显示?
{{#if isLogged}}
<li><a href="#">Logout</a></li>
{{else}}
<li><a href="#">Login</a></li>
{{/if}}
答案 0 :(得分:1)
您需要将第二个输入添加到Route的控制器中。
App.Route = Ember.Route.extend({
model : function(){
return posts;
},
setupController(controller, model){
controller.set("model", model);
controller.set("isLogged", status);
}
});
由于isLogged
将在控制器中声明,因此它应该在视图中可见。