emberjs之加载
2015-09-05 21:53
549 查看
默认加载规则
在emberjs中,类的名字是很有用的,它连接各个方法的方式默认是根据各个类的名字。App.Router.map(function() { this.resource('posts', function() { // the `posts` route this.route('favorites'); // the `posts.favorites` route this.resource('post'); // the `post` route }); });
资源的名称与路由,控制器或模板的起始名称一致。即使post资源被嵌套了,它的路由的名称 仍是App.PostRoute, 控制器名称是App.PostController,模板名称是post.
自定义加载规则
当然,如果不想使用默认加载的方式,那么会提供一个方式来进行自定义加载的对象。如果不想渲染与路由处理方法相关联的那个模板,那你就要实现renderTemplate 钩子来覆盖默认行为。
App.PostsRoute = Ember.Route.extend({ renderTemplate: function() { this.render('favoritePost'); } });
如果你希望使用一个不同的控制器来取代路由处理方法默认的控制器,那就需要在传递的参数中附上controller的名称。
App.PostsRoute = Ember.Route.extend({ renderTemplate: function() { this.render({ controller: 'favoritePost' }); } });
相关文章推荐
- javascript实现继承的6种方式
- Javascript闭包演示【转】
- [连载]Tutorial series: learning how to write a 3D soft engine from scratch in C#, TypeScript or JavaScript[英]
- Js中的this和window.event.srcElement
- JavaScript学习笔记(一)
- Javascript高级程序设计——BOM(浏览器对象模型)
- jsp分页代码
- JSR 303 - Bean Validation 介绍及最佳实践
- Javascript中的事件绑定
- JavaScript实现用户注册表单的简单检查
- 关于使用JavaScript实现图片点击切换(附带改变导航图片 方案二)
- JavaScript技巧(二)续
- angular js的一些操作
- js 页面跨域
- 了解 JavaScript 应用程序中的内存泄漏
- JavaScript实现分类列表显示与隐藏的切换
- JavaScript实现动态倒计时跳转页面
- (一)我的Javascript系列:Javascript的面向对象旅程(上)
- JS中子类中如何调用父类的同名方法(继承时候,父类的同名方法被覆盖了)
- js控制滚动条联动