Prepare for Angular Interviews with real-life questions. Utilize quizzes and examples to deepen understanding and enhance your skills. Gear up to ace your interview!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which of the following directives is NOT used in Angular templates?

  1. *ngFor

  2. *ngIf

  3. ng-bind

  4. (event)

The correct answer is: ng-bind

The reasoning behind selecting ng-bind as the correct answer lies in understanding the specific context and syntax of Angular directives. In Angular frameworks, *ngFor and *ngIf are well-known structural directives, which manipulate the DOM by adding or removing elements based on conditions and iterations. They are particularly designed for creating templates that can dynamically render based on the state of the application. In contrast, ng-bind is not utilized in Angular's template syntax. Instead, it originates from AngularJS (the original version of Angular) and serves the purpose of binding data to an HTML element's inner HTML. As Angular evolved, it introduced new binding syntaxes like interpolation (using double curly braces), property binding, and event binding, which made ng-bind obsolete in the newer versions of Angular. The phrase (event) also aligns with Angular's event binding functionality. Angular uses this notation to bind events in templates, such as clicks or key presses, making it a valid directive. Therefore, across the different elements of Angular's template syntax, ng-bind stands out as the directive that does not belong in the context of Angular templates, confirming it as the correct choice in this scenario.