Help Angular by taking a 1 minute survey!Go to surveyHome

By

Predicates for use with DebugElement's query functions.

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

Static methods

Match all elements.

static all(): Predicate<DebugElement>
      
      static all(): Predicate<DebugElement>
    
Parameters

There are no parameters.

Returns

Predicate<DebugElement>

Usage Notes

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

Match elements by the given CSS selector.

static css(selector: string): Predicate<DebugElement>
      
      static css(selector: string): Predicate<DebugElement>
    
Parameters
selector string
Returns

Predicate<DebugElement>

Usage Notes

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

Match elements that have the given directive present.

static directive(type: Type<any>): Predicate<DebugElement>
      
      static directive(type: Type<any>): Predicate<DebugElement>
    
Parameters
type Type
Returns

Predicate<DebugElement>

Usage Notes

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