Principais perguntas e respostas de entrevista e testes online
Plataforma educacional para preparacao de entrevistas, testes online, tutoriais e pratica ao vivo

Desenvolva habilidades com trilhas de aprendizado focadas, simulados e conteudo pronto para entrevistas.

WithoutBook reune perguntas de entrevista por assunto, testes praticos online, tutoriais e guias comparativos em um unico espaco de aprendizado responsivo.

Preparar entrevista

Angular perguntas e respostas de entrevista

Diferencas relacionadas

Diferencas relacionadas

Jquery vs AngularJSAngularJS vs NodeJSAngularJS vs Angular
Angular vs React

Pergunta 21. What is the purpose of async pipe?

The AsyncPipe subscribes to an observable or promise and returns the latest value it has emitted. When a new value is emitted, the pipe marks the component to be checked for changes.

Let's take a time observable which continuously updates the view for every 2 seconds with the current time.

@Component({

  selector: 'async-observable-pipe',

  template: `<div><code>observable|async</code>: Time: {{ time | async }}</div>`

})

export class AsyncObservablePipeComponent {

  time = new Observable(observer => setInterval(() => observer.next(new Date().toString()), 2000) );

}

Isto e util? Adicionar comentario Ver comentarios
 

Pergunta 22. What is the option to choose between inline and external template file?

You can store your component's template in one of two places. You can define it inline using the template property, or you can define the template in a separate HTML file and link to it in the component metadata using the @Component decorator's templateUrl property.

The choice between inline and separate HTML is a matter of taste, circumstances, and organization policy. But normally we use inline template for small portion of code and external template file for bigger views. By default, the Angular CLI generates components with a template file. But you can override that with the below command,

ng generate component hero -it

Isto e util? Adicionar comentario Ver comentarios
 

Pergunta 23. What is the purpose of ngFor directive?

We use Angular ngFor directive in the template to display each item in the list. For example, here we iterate over list of users,

<li *ngFor="let user of users">

  {{ user }}

</li>

The user variable in the ngFor double-quoted instruction is a template input variable

Isto e util? Adicionar comentario Ver comentarios
 

Pergunta 24. What is the purpose of ngIf directive in Angular?

Sometimes an app needs to display a view or a portion of a view only under specific circumstances. The Angular ngIf directive inserts or removes an element based on a truthy/falsy condition. Let's take an example to display a message if the user age is more than 18,

<p *ngIf="user.age > 18">You are not eligible for student pass!</p>

Note: Angular isn't showing and hiding the message. It is adding and removing the paragraph element from the DOM. That improves performance, especially in the larger projects with many data bindings.

Isto e util? Adicionar comentario Ver comentarios
 

Pergunta 25. What happens if you use script tag inside template?

Angular recognizes the value as unsafe and automatically sanitizes it, which removes the script tag but keeps safe content such as the text content of the script tag. This way it eliminates the risk of script injection attacks. If you still use it then it will be ignored and a warning appears in the browser console.

Let's take an example of innerHtml property binding which causes XSS vulnerability,

export class InnerHtmlBindingComponent {

  // For example, a user/attacker-controlled value from a URL.

  htmlSnippet = 'Template <script>alert("0wned")</script> <b>Syntax</b>';

}

Isto e util? Adicionar comentario Ver comentarios
 

Mais uteis segundo os usuarios:

Copyright © 2026, WithoutBook.