填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

By

DebugElement的查询功能一起使用的谓词。

Predicates for use with DebugElement's query functions.

      
      class By {
  static all(): Predicate<DebugNode>
  static css(selector: string): Predicate<DebugElement>
  static directive(type: Type<any>): Predicate<DebugNode>
}
    

静态方法

Match all nodes.

      
      static all(): Predicate<DebugNode>
    
参数

没有参数。

返回值

Predicate<DebugNode>

使用说明

Example
      
      debugElement.query(By.all());
    

通过给定的 CSS 选择器匹配元素。

Match elements by the given CSS selector.

      
      static css(selector: string): Predicate<DebugElement>
    
参数
selector string
返回值

Predicate<DebugElement>

使用说明

Example
      
      debugElement.query(By.css('[attribute]'));
    

匹配存在给定指令的节点。

Match nodes that have the given directive present.

      
      static directive(type: Type<any>): Predicate<DebugNode>
    
参数
type Type
返回值

Predicate<DebugNode>

使用说明

Example
      
      debugElement.query(By.directive(MyDirective));