我在几个星期内开了一个角度研讨会,我不确定是否教他们关于$scope或者教他们controller as语法。
继续前进到Angular 2.0,范围摆脱了。 但是, $scope是我学习的核心部分。
所以我的问题是 - 向前迈进,你会宣讲$scope或controller as吗?
I'm running an angular workshop in a few weeks, and am unsure whether to teach them about $scope or teach them the controller as syntax.
Moving forward to Angular 2.0, scopes are rid of. But $scope was a core part of my learning.
So my question is - moving forward, will you be preaching about $scope or controller as?
最满意答案
如果您正在教授Angular 1.x,那么无论您是否计划将controller as语法,您都必须了解scope及其在Angular中的工作方式。 在Angular 1.x中,对摘要周期,范围层次,隔离范围的理解是必不可少的。
我建议的是先从教学开始,然后使用标准范围基本绑定和数据共享机制构建一些初始样本。
然后,您可以将controller as语法引入controller as并将其与范围使用进行对比,并突出显示为什么它比使用scopes更好,以及Angular 2如何完全摆脱范围的概念。
If you are teaching Angular 1.x, they you will have to instil the understanding of scope and how they work in Angular, irrespective of whether you are planning to use controller as syntax. The understanding of digest cycle, scope hierarchy, isolated scope are essential in Angular 1.x.
What i will suggest is to start with teaching then about scope and build some initial samples using standard scope base binding and data sharing mechanism.
Then you can introduce controller as syntax and contrast it against scope usage and highlight why is it better than using scopes and how Angular 2 is getting rid of the concept of scope altogether.
更多推荐
发布评论