started review for attribute-directives.jade.

This commit is contained in:
Zhimin YE (Rex) 2016-05-26 17:04:19 +01:00
parent 21b13126da
commit 5031e6fe94
1 changed files with 4 additions and 3 deletions

View File

@ -83,6 +83,7 @@ a#write-directive
:marked :marked
## Build a simple attribute directive ## Build a simple attribute directive
## 创建一个简单的属性型指令 ## 创建一个简单的属性型指令
An attribute directive minimally requires building a controller class annotated with An attribute directive minimally requires building a controller class annotated with
`@Directive`, which specifies the selector identifying `@Directive`, which specifies the selector identifying
the attribute associated with the directive. the attribute associated with the directive.
@ -176,14 +177,14 @@ p
each matching element, injecting an Angular `ElementRef` each matching element, injecting an Angular `ElementRef`
into the constructor. into the constructor.
Angular会为每个被指令匹配上的元素创建一个控制器类的实例并把Angular的`ElementRef`注入进它的构造函数。 Angular会为每个被指令匹配上的元素创建一个该指令控制器类的实例并把Angular的`ElementRef`注入进它的构造函数。
`ElementRef` is a service that grants us direct access to the DOM element `ElementRef` is a service that grants us direct access to the DOM element
through its `nativeElement` property. through its `nativeElement` property.
That's all we need to set the element's background color using the browser DOM API. That's all we need to set the element's background color using the browser DOM API.
`ElementRef`是一个服务,通过它的`nativeElement`属性,我们可以直接访问到这个DOM元素。 `ElementRef`是一个服务,通过它的`nativeElement`属性,我们可以直接访问到指令所在DOM元素。
我们所要做的,就是使用浏览器的DOM API来设置这个元素的背景色。 就是使用浏览器的DOM API来设置这个元素的背景色所需要我们做的全部
.l-main-section .l-main-section
a#apply-directive a#apply-directive