By

From Get docs
< @angular/platform-browserAngular/docs/11/api/platform-browser/by


By

class

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>
}

Static methods

Match all nodes.

static all(): Predicate<DebugNode>

Parameters

There are no parameters.

Returns

Predicate<DebugNode>


Usage Notes

Example
debugElement.query(By.all());
Match elements by the given CSS selector.

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

Parameters
selector string
Returns

Predicate<DebugElement>


Usage Notes

Example
debugElement.query(By.css('[attribute]'));
Match nodes that have the given directive present.

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

Parameters
type Type
Returns

Predicate<DebugNode>


Usage Notes

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


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