Mac下通过别名在命令行中打开SublimeText
:
|
|
应用场景:
|
|
Quick notes
Mac下通过别名在命令行中打开SublimeText
:
|
|
应用场景:
|
|
Scopes are a core fundamental of any Angular app. They are used all over the framework, so it’simportant to know them and how they work.The scopes of the application refer to the application model. Scopes are the execution context for expressions.
The $scope
object is where we define the business functinality of the application, the methods in our controllers, and properties in the views. Scopes serve as the glue between the controller and the view. Just before our app renders the view to the user, the view template links to the scope, and the app sets up the DOM to notify Angularfor property changes. This feature makes it easy to account for promises, such as an XHR call, to be fulfilled. See the promises chapter for more details.
Scopes are the source of truth for the application state. Because of this live binding, we can relyon the $scope
to update immediately when the view modifies it, and we can rely on the view to update when the $scope
changes. $scopes
in AngularJS are arranged in a hierarchical structure that mimics the DOM and thus arenestable: We can reference properties on parent $scopes.
If you are familiar with JavaScript, then this hierarchical concept shouldn’t be foreign. When we create a new execution context in JavaScript, we create a new function that effectively creates a new ‘local’ context. The Angular concept of $scopes
is similar in that as we create a new scope for child DOM elements,we are creating a new execution context for the DOM to live in.
Scopes provide the ability to watch for model changes. They give the developer the ability to propagate model changes throughout the application by using the apply mechanism available on the scope. We define and execute expressions in the context of a scope; it is also from here that we can propagate events to other controllers and parts of the application.It is ideal to contain the application logic in a controller and the working data on the scope of the controller.
From: ngBook - scopes
一位参观英格兰伊顿公学的游客问那里的园丁,他是怎样让草坪变得如此完美的。“那很容易,”园丁回答说,“你只要每天早晨拂去卤水,每隔一天割一次草,每个星期碾压以此就行了。”
“就是这些吗?”游客问。
“就是这些,”园丁回答说,“这样做上500年,你也将拥有一片漂亮的草坪。”
了不起的草坪需要每一天给予一点关心,了不起的程序员也是这样。管理顾问们喜欢在谈话中扔出“Kaizen”这个词,“Kaizen”是一个日本术语,表达的是持续的做出许多小改进的概念。它被认为是日本制造业在生产率与质量方面取得长足进步的主要原因之一,并且在世界各地得到了广泛的效仿。Kaizen也适用于个人。每天为提炼你所拥有的技能而工作,为把新的工具增加到你的技能列表中而工作。与伊顿的草坪不同,你在几天之中就将开始看到结果。几年之后,你将会惊奇你的经验得到了怎样的发展,你的技能得到怎样的提升。
《程序员修炼之道》