当前位置: 首页 > 软件库 > Web应用开发 > Web框架 >

Angular-Interview-Questions

授权协议 Readme
开发语言 JavaScript
所属分类 Web应用开发、 Web框架
软件类型 开源软件
地区 不详
投 递 者 严曜文
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Angular-Interview-Questions

This file contains a number of Angular interview questions that can be used when vetting potential candidates. It is by no means recommended to use every single question here on the same candidate (that would take hours). Choosing a few items from this list should help you vet the intended skills you require.

A developer is perfectly able to use Angular to build applications without being able to answer all of these questions. Addition to having a source for interview questions, my intention is to encourage interested developers to think about these questions. I regularly teach Angular workshops. Oftentimes I do not get enough questions due to limited exposure working with the framework. These questions are the ones I personally needed to answer, to be able lead a team developing our first Angular production application at Autodesk A360.

Note: Keep in mind that many of these questions are open-ended and could lead to interesting discussions that tell you more about the person's capabilities than a straight answer would.

Table of Contents

General Questions:

  • What did you learn about Angular yesterday/this week?
  • What are some of the reasons you would choose to use Angular in your project?
  • What did you like about working with Angular?
  • How do you keep your Angular code more readable and maintainable?
  • What does testable code mean to you in context of Angular?
  • What does reusable code mean to you in context of Angular?

Animations Questions:

  • How do you define transition between two states in Angular?
  • How do you define a wildcard state?

Architecture Questions:

  • What is a good use case for ngrx/store?
  • What is a good use case for ngrx/entity?
  • Can you talk about a bug related to a race condition, how to solve it and how to test it?
  • What is the difference between a smart/container component and dumb/presentational component? What is a good use case example? What are the advantages?

API Questions:

  • What does this code do:
@HostBinding('class.valid') isValid;
<div *ngIf='someObservableData | async as data; else loading'>{{data}}</div>

<ng-template #loading>
  Loading Data...
</ng-template>
  • Why would you use renderer methods instead of using native element methods?
  • How would you control size of an element on resize of the window in a component?
  • What would be a good use for NgZone service?
  • What are the bootstrap options for NgZone? Why would you use them? (Angular 5+)
  • How would you protect a component being activated through the router?
  • How would you insert an embedded view from a prepared TemplateRef?
  • What is the difference between @ViewChild() and @ContentChild()

Template Syntax Questions:

  • How can you add an active class to a selected element in a list component?
  • What is a template variable. How would you use it?
  • What is the difference of using a property binding verses a function binding on a template?
  • What happens if you subscribe to a data source multiple times with async pipe?
  • What is the difference between ng-content, ng-container and ng- template?
  • When you create a data-binding in Angular, are you working with attributes or properties? What is the difference anyway?
  • When can you omit the brackets in template binding?

Component Questions:

  • What is the minimum definition of a component?
  • What is the difference between a component and a directive?
  • How do components communicate with each other?
  • How do you create two way data binding in Angular?
  • How would you create a component to display error messages throughout your application?
  • What does a lean component mean to you?

Component Interaction & State Management Questions:

  • How would you pass data from a parent component to a child component?
  • How would you pass data from a child component to a parent component?
  • Which components will be notified when an event is emitted?
  • Tell me about the different ways how you would get data to your components from a service and talk about why would you use one way vs the other?
  • How would you use cached data?

Forms Questions:

  • When do you use template driven vs model driven forms? Why?
  • How do you submit a form?
  • What's the difference between NgForm, FormGroup, and FormControl? How do they work together?
  • What's the advantage of using FormBuilder?
  • How do you add form validation to a form built with FormBuilder?
  • What's the difference between dirty, touched, and pristine on a form element?
  • How can you access validation errors in the template to display error messages?
  • What is async validation and how is it done?
  • What is the correct form control class name which is set to true when value is modified?

NgModules Questions:

  • What is the purpose of NgModule?
  • How do you decide to create a new NgModule?
  • What are the attributes that you can define in an NgModule annotation?
  • What is the difference between a module's forRoot() and forChild() methods and why do you need it?
  • What is providedIn property used for in an NgModule?
  • What would you have in a shared module?
  • What would you not put shared module?
  • What module would you put a singleton service whose instance will be shared throughout the application (e.g. ExceptionService andLoggerService)?
  • What is the purpose of exports in a NgModule?
  • What is the difference between exports and declarations in NgModule?
  • Why is it bad if SharedModule provides a service to a lazy loaded module?

Services Questions:

  • What is the use case of services?
  • How are the services injected to your application?
  • How do you unit test a service with a dependency?
  • Why is it a bad idea to create a new service in a component like the one below?
let service = new DataService();

Structural Directives Questions:

  • What is a structural directive?
  • How do you identify a structural directive in html?
  • When creating your own structural directives, how would you decide on hiding or removing an element? What would be the advantages or disadvantages of choosing one method rather than the other?

Style Guide Questions:

  • What are some of the Angular Style Guide suggestions you follow on your code? Why?
  • Is it important to have a style guide? Why/not?

Styling Questions:

  • How would you select a custom component to style it.
  • What pseudo-class selector targets styles in the element that hosts the component?
  • How would you select all the child components' elements?
  • How would you select a css class in any ancestor of the component host element, all the way up to the document root?
  • What selector force a style down through the child component tree into all the child component views?
  • What does :host-context() pseudo-class selector targets?
  • What does the following css do?
:host-context(.theme-light) h2 {
  background-color: red;
}

Lifecycle Hooks Questions:

  • What is the possible order of lifecycle hooks.
  • When will ngOnInit be called?
  • How would you make use of ngOnInit()?
  • What would you consider a thing you should be careful doing on ngOnInit()?
  • What is the difference between ngOnInit() and constructor() of a component?
  • What is a good use case for ngOnChanges()?

Observables RxJS Questions:

  • What is the difference between an observable and a promise?
  • What is the difference between an observable and a subject?
  • What are some of the angular apis that are using observables?
  • How would you cache an observable data?
  • How would you implement a multiple api calls that needs to happen in order using rxjs?
  • What is the difference between switchMap, concatMap and mergeMap?
  • How would you make sure an api call that needs to be called only once but with multiple conditions. Example: if you need to get some data in multiple routes but, once you get it, you can reuse it in the routes that needs it, therefor no need to make another call to your backend apis.
  • How would you implement a brush behavior using rxjs?
  • How would you implement a color picker with rxjs?
  • If you need to respond to two different Observable/Subject with one callback function, how would you do it?(ex: if you need to change the url through route parameters and with prev/next buttons).
  • What is the difference between scan() vs reduce() ?

Performance Questions:

  • What are some of the things that you pay attention to, to make sure your angular application is performant?
  • What tools would you use to find a performance issue in your code?
  • What tools have you used to improve the performance of your application?
  • What are some ways you may improve your website's scrolling performance?
  • Explain the difference between layout, painting and compositing.
  • Have you seen Jeff Cross's NgCruise talk on performance?

Pipes Questions:

  • What is a pure pipe?
  • What is an async pipe?
  • What kind of data can be used with async pipe?
  • How do you create a custom pipe?
  • How does async pipe prevents memory leeks?
  • What is the difference between pure and impure pipes?

Router Questions:

  • What is the difference between RouterModule.forRoot() vs RouterModule.forChild()? Why is it important?
  • How does loadChildren property work?
  • Do you need a Routing Module? Why/not?
  • When does a lazy loaded module is loaded?
  • Below link doesn't work. Why? How do I fix it?
<div routerLink='product.id'></div>
  • Can you explain the difference between ActivatedRoute and RouterState?
  • How do you debug router?
  • Why do we need route guards?
  • What is a RouterOutlet?

Security Questions:

Testing Questions:

  • What are some of the different tests types you can write?
  • How do you mock a service to inject in an integration test?
  • How do you mock a module in an integration test?
  • How do you test a component that has a dependency to an async service?
  • What is the difference between 'async()' and 'fakeAsync()'?

TypeScript Questions:

  • Why do you need type definitions?
  • How would you define a custom type?
  • What is the difference between an Interface and a Class?
  • First line below gives compile error, second line doesn't. Why?
someService.someMethod(x);
someService['someMethod'](x);
  • What are Discriminated union types?
  • How do you define Object of Objects type in typescript?
  • How can you capture the 'type' the user provides (e.g. number), so that we can use that information later.

JavaScript Questions:

  • Explain the difference between var, let and const key words.
  • Could you make sure a const value is garbage collected?
  • Explain Object.assign and possible use cases.
  • Explain Object.freeze and possible use cases.
  • Explain the code below. How many times the createVal function is called?
function createVal(){
  return Math.random();
};

function fun( val =  createVal()){
  // Do something with val...
}

fun();
fun(5);
  • What is the spread operator doing in this function call? Seriously!
doStuff(...args);
  • What is destructuring assignment?
  • Explain why the below stand-alone syntax is not valid?
{a, b} = {a: 1, b: 2}

Coding Questions:

  • What would these components render?
import { Component, ContentChildren, Directive, Input, QueryList } from '@angular/core';

@Directive({selector: 'pane'})
export class Pane {
  @Input() id: string;
}

@Component({
  selector: 'tab',
  template: `
    <div>panes: {{serializedPanes}}</div>
  `
})
export class Tab {
  @ContentChildren(Pane) panes: QueryList<Pane>;
  get serializedPanes(): string { return this.panes ? this.panes.map(p => p.id).join(', ') : ''; }
}

@Component({
  selector: 'example-app',
  template: `
    <tab>
      <pane id="1"></pane>
      <pane id="2"></pane>
      <pane id="3" *ngIf="shouldShow"></pane>
    </tab>
    <button (click)="show()">Show 3</button>
  `,
})
export class ContentChildrenComp {
  shouldShow = false;
  show() { this.shouldShow = true; }
}

Fun Questions:

  • What's a cool project that you've recently worked on?
  • What are some things you like about the developer tools you use?
  • Who inspires you in the angular community?
  • Do you have any pet projects? What kind?
  • How did you design the architecture of your project?
  • What's your favorite feature of Angular?
  • What is your least favorite thing about Angular? (Please share your thoughts by making a pull request to angularFeelings)
  • How do you like your coffee?
  • If you could decide on a new feature for angular, what would it be?
  • What is Ivy and how do you enable it?

Contributors:

  • 一,  Angular 于 AngularJS 的区别 angularJs 优点: 模块功能强大丰富, 支持数据双向绑定; 比较完善的前端 MVC 框架; 引入 java 的概览, 比如依赖注入; angularJs 性能问题: 双向数据绑定, 项目变大的时候,性能影响很大, 采用脏检查,跟踪数据变化,动态改变用户数据 Angular:  全新的命令行工具 angular-cli; 默认是单向数据

  • 1、结果:    代码分离时,运行浏览器控制台报错:[ng:areq] 2、原因:   在.html页面定义了app,但是却没有引用 3、解决:   删除.html中的没有用到的 var app = angular.module('brand',[]);

  • 1.What are the pop-up boxes available in JavaScript? Alert Box Confirm Box Prompt Box Example of alert() in JavaScript <script type="text/javascript"> function msg(){ alert("Hello Alert Box");

  • 1. ng-if 跟 ng-show/hide 的区别有哪些? 第一点区别是,ng-if 在后面表达式为 true 的时候才创建这个 dom 节点,ng-show 是初始时就创建了,用 display:block 和 display:none 来控制显示和不显示。 第二点区别是,ng-if 会(隐式地)产生新作用域,ng-switch 、 ng-include 等会动态创建一块界面的也是如此 2.

  • HTML是什么? Hyper text mark-up language.超文本标记语言,用来开发网页的语言,主要以标签对添形式,为文本添加“语义”,放置文档的部件 如何创建网页? 用IDE创建.index文件。创建text文件改成.index,为什么可以这么做?因为html本身就是纯文本的。 如何浏览网页? 直接打开.html文件,浏览器会负责解析,可以通过extension of live s

  • 1.What is JavaScript? JavaScript is a scripting language. It is different from Java language. It is object-based, lightweight, cross-platform translated language. It is widely used for client-side val

  • https://github.com/xufei/blog/issues/15 【文章评论更赞,建议多看多了解】 在过去半年里,我跟一些潜在客户进行了交谈,他们在寻找前端顾问来帮助开发团队控制Angular项目的时候,遇到了麻烦。 尽管有一些对Angular很热情的前端人员,我有种感觉,对于一个主流框架来说,他们的数量还是太少了。我期望Angular能比之前受到更多关注。 Angular更多地是面

  • 十六进数由数字 0-15 组成,用前缀 0x 或者 0X 表示 16 进制数 `print(hex(16))#0x10 print(hex(15))#0xf ` 121. 怎样声明多个变量并赋值? **答:**Python 是支持多个变量赋值的,代码示例如下 `#对变量 a,b,c 声明并赋值 a,b,c = 1,2,3 ` 算法和数据结构 122. 已知: `AList = [1,2,3] BS

  • AngularJS是一个JavaScript框架,通过ng-directives(指令)扩展了HTML。 ng-app指令定义一个AngularJS应用程序。 ng-model指令把元素值(比如输入域input的值)绑定到应用程序。 ng-bind指令把应用程序绑定到HTML视图。 AngularJS指令是以ng作为前缀的HTML属性,AngularJS 模块(Module) 定义了 Angula

  • mail-side.type.ts export interface Record { sessionId?: string; endTime?: number; mainSessionId?: string; startTime: number; } 应用 import { Record } from './mail-side.type'; record: R

 相关资料
  • 亲爱的读者们,这些Angular 2 Interview Questions专门设计用于让您熟悉在面试Angular 2时可能遇到的问题的本质。 根据我的经验,好的面试官在你的面试中几乎不打算问任何特定的问题,通常问题从这个主题的一些基本概念开始,然后他们继续基于进一步的讨论和你回答的内容: 什么是Angular 2? AngularJS是一个构建大规模和高性能Web应用程序的框架,同时使它们易于

  • Interview 大前端每日一题,从基础到进阶,从原理到实战,用面试题来倒逼强迫自己每天去学习去查漏补缺,系统构建前端完整的知识体系!注:每天早上9点左右更新题目及前一天的答案,首页文件夹里的文章来源于网络,仅供参考学习使用,若有侵权,烦请联系我删除!(有时github访问不太稳定,更新可能会有延迟) 业精于勤,荒于嬉;行成于思,毁于随!学习从来都不是一蹴而就的事情,需要每天的点滴积累与沉淀,从

  • 亲爱的读者们,这些Spring Interview Questions专门设计用于让您熟悉在面试Spring时可能遇到的问题的本质。 根据我的经验,好的面试官在你的面试中几乎不打算问任何特定的问题,通常问题从这个主题的一些基本概念开始,然后他们继续基于进一步的讨论和你回答的内容: 什么是Spring? Spring是企业Java的开源开发框架。 Spring Framework的核心功能可用于开发

  • 亲爱的读者,这些Python Programming Language Interview Questions专门设计用于让您熟悉在Python Programming Language主题面试中可能遇到的问题的本质。 根据我的经验,很好的面试官在你的面试中几乎不打算问任何特定的问题,通常问题从这个主题的一些基本概念开始,然后他们继续基于进一步的讨论和你回答的问题 - 什么是Python? Pyt

  • 亲爱的读者们,这些Struts2 Interview Questions专门设计用于让您熟悉Struts2 Programming主题面试中可能遇到的问题的本质。 根据我的经验,优秀的面试官在你的面试中几乎没有计划提出任何特定的问题,通常问题从这个主题的一些基本概念开始,后来他们继续基于进一步的讨论和你回答的问题 - 什么是Struts2? Struts2是基于MVC设计模式的流行且成熟的Web应

  • 亲爱的读者,这些JavaScript Interview Questions专门设计用于让您熟悉在面试JavaScript时可能遇到的问题的本质。 根据我的经验,好的面试官在你的面试中几乎不打算问任何特定的问题,通常问题从这个主题的一些基本概念开始,然后他们继续基于进一步的讨论和你回答的内容: 什么是JavaScript? JavaScript是一种轻量级的解释型编程语言,具有面向对象的功能,允许