$ scope的角度最佳实践

编程入门 行业动态 更新时间:2024-10-23 11:22:30
$ scope的角度最佳实践 - 当你在教新手时(Angular Best Practices on $scope - when you're teaching newbies)

我在几个星期内开了一个角度研讨会,我不确定是否教他们关于$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.

更多推荐

本文发布于:2023-08-04 13:33:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415953.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:角度   scope

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!