本文介绍了有人可以分解公约与emberjs的配置方面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了MVC的概念方面,以及它们是如何实现的。在emberjs中,公约方法是有道理的,看起来很简单。但是,您如何决定何时使用objectcontroller与indexedcontroller等,以及如何学习或保留约定,以便您可以快速进行逻辑编程设计决策,以决定您采用哪种方向或方法?

我的意思是你如何将这样的分钟公约作为逻辑思维?



另外,相应地有没有关于视图与组件与属性的约定,以及这些方法是如何从围绕路由,路由器,控制器的约定中排除的?



谢谢 -



David

解决方案

控制器是真正的装饰器。它们将控制器的属性代理到其下的模型。因此,有三种不同类型的控制器。 ArrayController ObjectController 控制器



ArrayController 由集合支持



ObjectController 由单个对象支持



控制器没有任何对象支持它



真的是诀窍是开始小。单一模板,单路,单控制器。不要尝试添加任何东西,直到遇到问题,你不知道如何解决。



示例:



一旦获得了一条路线的要点,单控制器,单个模板,就可以开始尝试多个路线等。这很像大学,实验的时间,但你开始小。



示例:


I get the conceptual aspects of MVC and how they are generally implemented. In emberjs the conventions approach makes sense and is seemingly straightforward. But, how do you decide when to use an objectcontroller vs. an indexedcontroller and such, and how is one to learn or retain the conventions so you can make quick logical programmatic design decisions as to which direction or approach you take?

I mean how do you commit such minute conventions like these into logical thinking?

http://emberjs.com/guides/concepts/naming-conventions/#toc_route-controller-and-template-defaults

Also, correspondingly are there conventions around views vs. a component vs. a property and how those all funnel out from the conventions around routing, routers, controllers?

thanks -

David

解决方案

Controller's are really decorators. They proxy properties from the controller to the model beneath it. As such there are three different types of controllers. ArrayController, ObjectController, and Controller.

ArrayController is backed by a collection

ObjectController is backed by a single object

Controller doesn't have any object backing it

Really the trick is to start small. Do a single template, single route, single controller. Don't attempt to add anything else until you run into a problem you don't know how to solve.

Example: http://emberjs.jsbin.com/sohijunu/1/edit

Once you get the gist of a single route, single controller, single template, you can start experimenting with multiple routes etc. It's a lot like college, a time of experimentation, but you start small.

Example: http://emberjs.jsbin.com/OxIDiVU/726/edit

这篇关于有人可以分解公约与emberjs的配置方面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 02:18