- An ElementRef is created for each element in the Template that contains a Directive, Component or data-binding.
- An ElementRef is backed by a render-specific element. In the browser, this is usually a DOM element.
Template、Directive里用ElementRef 知道,data-binding怎么用还不清楚
data-binding指的是 #ref
import {Component,ElementRef,ViewChild} from 'angular2/core' |
能不用这个就不用,一般操作DOM用Renderer
export abstract class ElementRef { |
这个nativeElement 是DOM对象不是Jq对象,举例
<result class="col-xs-2 col-xs-offset-1 resultItem itemSpace" _ngcontent-hev-3="" _nghost-hev-4=""> |