我刚刚开始使用Ember.js构建测试应用程序。我正在尝试绑定到ApplicationController
,以便我的名字在application
模板中呈现。我无法让它发挥作用!
我正在关注http://emberjs.com/guides/templates/handlebars-basics/
中提供的信息以下是我正在使用的代码:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<link href="/Content/css/style.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/lib/jquery.js" type="text/javascript"></script>
<script src="/Scripts/lib/handlebars.js" type="text/javascript"></script>
<script src="/Scripts/lib/ember.js" type="text/javascript"></script>
</head>
<body>
<script type="text/x-handlebars">
<h1>Welcome to my test application</h1>
<div>
Hello, <strong>{{firstName}} {{lastName}}</strong>!
</div>
</script>
<script type="text/javascript">
$(function () {
MyApp = Ember.Application.create();
MyApp.ApplicationController = Ember.Controller.extend({
firstName: "Jones",
lastName: "Ross"
});
});
</script>
</body>
</html>
输出结果为:
Welcome to my test application
Hello, !
firstName
和lastName
似乎是undefined
!没有错误产生。
答案 0 :(得分:0)