{ "id": "api/platform-browser/By", "title": "By", "contents": "\n\n
\n
\n
\n \n API > @angular/platform-browser\n
\n \n
\n \n
\n

Bylink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

Predicates for use with DebugElement's query functions.

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

Static methodslink

\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n \n \n
\n
\n

\n all()\n \n link

\n \n
\n
\n

Match all nodes.

\n\n
\n
\n \n\n static all(): Predicate<DebugNode>\n\n \n\n
Parameters
\n

There are no parameters.

\n\n \n
Returns
\n

Predicate<DebugNode>

\n\n \n\n\n \n\n \n
\n
\n

Usage Noteslink

\n
Examplelink
\n\ndebugElement.query(By.all());\n\n\n\n
\n\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n \n \n
\n
\n

\n css()\n \n link

\n \n
\n
\n

Match elements by the given CSS selector.

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

Predicate<DebugElement>

\n\n \n\n\n \n\n \n
\n
\n

Usage Noteslink

\n
Examplelink
\n\ndebugElement.query(By.css('[attribute]'));\n\n\n\n
\n\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n \n \n
\n
\n

\n directive()\n \n link

\n \n
\n
\n

Match nodes that have the given directive present.

\n\n
\n
\n \n\n static directive(type: Type<any>): Predicate<DebugNode>\n\n \n\n
Parameters
\n \n \n \n \n \n \n \n \n \n
\n \n type\n Type\n \n \n
\n\n \n
Returns
\n

Predicate<DebugNode>

\n\n \n\n\n \n\n \n
\n
\n

Usage Noteslink

\n
Examplelink
\n\ndebugElement.query(By.directive(MyDirective));\n\n\n\n
\n\n \n
\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n
\n
\n\n\n" }