By

class experimental

npm Package @angular/platform-browser
Module import { By } from '@angular/platform-browser';
Source platform-browser/src/dom/debug/by.ts

Overview

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

Description

Predicates for use with DebugElement's query functions.

Static Members

static all(): Predicate<DebugElement>

Match all elements.

Example

debugElement.query(By.all());

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

Match elements by the given CSS selector.

Example

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

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

Match elements that have the given directive present.

Example

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

© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v5.angular.io/api/platform-browser/By