我刚刚在http://trek.github.com/上阅读了Emberjs教程,但部分代码没有返回预期的输出。
我的HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.1.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.min.js"></script>
<script type="text/javascript" src="https://raw.github.com/emberjs/ember.js/release-builds/ember-1.0.0-rc.1.min.js"></script>
<script type="text/javascript" src="js/App.js"></script>
</head>
<body>
<div></div>
<script type="text/x-handlebars" data-template-name="application">
<h1>Ember committers</h1>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="contributors">
{{#each person in controller}}
{{person.login}}
{{/each}}
</script>
</body>
</html>
我的App.js(用App.coffee编写)
window.App = Ember.Application.create()
App.ApplicationView = Ember.View.extend
templateName:"application"
App.ApplicationController = Ember.Controller.extend()
App.AllContributorsController = Ember.ArrayController.extend()
App.AllControbutorsView = Ember.View.extend
templateName:"contributors"
App.Router = Ember.Router.extend
root:Ember.Route.extend
index:Ember.Route.extend
route:"/"
connectOutlets: (router) ->
router.get("applicationController").connectOutlet("allContributors", [{login:'wycats'},{login:'tomdale'}])
我希望打印出“wycats”和“tomdale”,但什么都没有。这是我的jsFiddle - http://jsfiddle.net/Djunu/
答案 0 :(得分:1)
您的代码基于过时的API。 Ember 1.0.rc有一种全新的,更友好的方式来定义路由和设置控制器。有关最新资料,请参阅本指南:http://emberjs.com/guides/routing/