gpt4 book ai didi

javascript - Ember 处理多次返回吗?

转载 作者:行者123 更新时间:2023-12-03 11:43:21 27 4
gpt4 key购买 nike

我有两个 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}}

最佳答案

您需要将第二个输入添加到路线的 Controller 中。

App.Route = Ember.Route.extend({
model : function(){
return posts;
},
setupController(controller, model){
controller.set("model", model);
controller.set("isLogged", status);
}
});

由于 isLogged 将在 Controller 中声明,因此它应该在 View 中可见。

关于javascript - Ember 处理多次返回吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26165642/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com