【发布时间】:2014-07-27 19:56:58
【问题描述】:
我已按照本教程 http://kroltech.com/2013/12/boilerplate-web-app-using-backbone-js-expressjs-node-js-mongodb/ 设置我的后端 node.js 服务器,但我想尝试 ember,而不是使用骨干木偶作为前端。因此,在成功设置服务器后,我现在正在学习 ember http://emberjs.com/guides/getting-started/ 的本教程。
我遇到的问题是将外部模板包含在我的 ember 路由中。使用此代码和在浏览器中编写的待办事项模板,应用程序可以正常工作。
var Ember = require('ember');
window.Todos = Ember.Application.create();
Todos.Router.map(function() {
this.resource('todos', { path: '/' });
});
但是,使用 ./templates/application.hbs 编写的模板并使用 browserify 进行尝试,
Todos.Router.map(function() {
this.resource(require('./templates/application.hbs'), { path: '/' });
});
我收到如下所示的错误。
Uncaught TypeError: undefined is not a function myapp.js:46841
Error: Assertion Failed: The URL '/' did not match any routes in your application
at new Error (native)
at Error.Ember.Error (http://localhost:3300/js/myapp.js:12978:19)
at Object.Ember.assert (http://localhost:3300/js/myapp.js:12141:11)
at http://localhost:3300/js/myapp.js:47347:15
at invokeCallback (http://localhost:3300/js/myapp.js:22081:19)
at publish (http://localhost:3300/js/myapp.js:21751:9)
at publishRejection (http://localhost:3300/js/myapp.js:22179:7)
at http://localhost:3300/js/myapp.js:30448:7
at Object.DeferredActionQueues.flush (http://localhost:3300/js/myapp.js:18195:24)
at Object.Backburner.end (http://localhost:3300/js/myapp.js:18283:27) myapp.js:15589
Uncaught Error: Assertion Failed: Error: Assertion Failed: The URL '/' did not match any routes in your application
我希望有人能阐明如何在 ember 路由器中包含外部模板。谢谢!
【问题讨论】:
-
传递给资源方法的第一个参数是资源名称。将模板插入页面可以在此之前进行,或者至少在构建模板之前进行。
标签: node.js ember.js browserify