如何显示“内容”?一个ObjectController? [英] How to display the "content" of an ObjectController?
本文介绍了如何显示“内容”?一个ObjectController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的ObjectController:
My ObjectController:
App.TestController = Ember.ObjectController.extend
content: null
App.testController = App.TestController.create()
App.testController.set("content", Ember.Object.create({ question: "Question?" }))
console.log App.testController.get("question")
我的视图:
{{#view App.QuizView controller="App.testController"}}
<div>"{{question}}"</div>
{{/view}}
在我的控制台上,我得到:
On my console, I get:
Question?
但是我的观点是空的:
""
我在做什么错了?
推荐答案
问题出在您的模板上,您没有将控制器绑定到视图。
替换
The problem comes from your template, you're not binding the controller to the view. Replace
{{#view App.QuizView controller="App.testController"}}
使用
{{#view App.QuizView controllerBinding="App.testController"}}
您可以尝试以下解决方案<在此JSFiddle中的href = http://jsfiddle.net/9Uvqf/ rel = nofollow> 。
You could try this solution in this JSFiddle.
这篇关于如何显示“内容”?一个ObjectController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文