Ember 的 currentPath 和 currentRouteName 始终未定义
Ember's currentPath and currentRouteName are always undefined
MyEmberApp.ApplicationRoute = Ember.Route.extend({
beforeModel: function() {
console.log(this);
console.log(this.controllerFor('application').get('currentPath')); // Undefined.
console.log(this.controllerFor('application').currentPath); // Undefined.
// console.log(this.controller.currentRouteName); // Undefined.
// console.log(Mars.__container__.lookup("controller:application").get("currentRouteName")); // Undefined.
// console.log(this.controllerFor("application").get("currentPath")); // Undefined.
// console.log(this.controllerFor("application").get("currentRouteName")); // Undefined.
this.transitionTo(THE ROUTE NAME I FIND...);
}
});
我做错了什么?甚至官方文档也说我必须这样做 http://emberjs.com/guides/understanding-ember/debugging/。
文档未能指定您需要在 ApplicationController
上手动创建此属性。
MyEmberApp.ApplicationController = Ember.Controller.extend({
currentPath: 'test12'
});
在 beforeModel hook 上,您还没有准备好控制器。尝试挂机设置控制器。
setupController(controller, model) {
this._super(controller, model);
debugger;
},
相关文章:
- 为什么“;未定义的“;在JavaScript中结束循环
- 要求未定义JS回调参数
- 如何检查管道中未定义的项目
- TypeError:无法读取属性'推'未定义的JavaScript
- $window.ga在AngularJS事件中未定义
- 未捕获的TypeError无法读取未定义的属性socialsharing
- 为什么grunt contrib connect的中间件选项的第三个参数是未定义的
- 无法获取属性'selectedIndex'的未定义引用或null引用
- 如何消除代码中的未定义和其他问题
- 未捕获的ReferenceError:$未定义
- this.router在AngularJS 2中未定义
- 未捕获的类型错误:无法读取属性'删除'的未定义
- 节点fs.stat名称未定义
- 尝试在PHP中回显输入文本时出现未定义的索引错误
- Jquery未定义函数正在停止其他操作
- AngularJS指令出错-无法读取属性'编译'的未定义
- 这.SOMETHING 总是返回未定义的 - extjs
- 无法获取属性'Id'使用Knockout.js的未定义或空引用API
- Wordpress中带有JQuery Accordion的未定义匿名函数
- 在不破坏未定义函数的情况下,对多个视图使用单个js文件