素材巴巴 > 程序开发 >

面试向:How did you use Angular?

程序开发 2023-09-03 15:16:53

what’s Ajax and RxJS?
Ajax stands for async JS and XML. used for local refresh.
RxJS stands for reactive extensions for JS. which is used for reactive programming, which thinks everything as event/streaming. It’s a library for reactive programming, using observable that makes it easier to compose asynchronous or callback-based code.

Why do we need angular framework?
makes the code easier for developers and divide the code into smaller bits of component.

How to config angular framework?
by angular.json
other important files
main.ts
index.html
app.component.ts

What’s the adv of angular?
tons of features provided by angular.
uses HTML to render the UI of an application
google will support angular in a long term.

Diff between AngularJS and Angular?
AngularJS uses a MVC pattern but Angular replace the controller with components (which is a predefined template)[Components modules and services]
AngularJS use JS but Angular use typescript.
AngularJS can’t support mobile but Angular support all.

what are lifecycle hooks in Angular?
每一个component都有自己的Lifecycle 我们需要经过不同的阶段。我们要用hooks来trigger components进入不同的phrase.
在这里插入图片描述

What’s angular directive?
指令。angular里面封装了一些Prebuilt指令 比如ng-app, ng-controller之类的 这个directive就是自定义指令,他是讲一段html js封装在一起 形成一个可以复用的独立的个体,句有具体特定的功能。

生命周期和钩子函数:
Angular 中每个 component/directive 都有它自己的生命周期。包括创建组件,渲染组件,创建渲染子组件,检测绑定属性变化,回收和从 DOM 中移除。【create, render components and subcomponents, update, recycle and delete】
生命周期有这几种:OnChanges,OnInit,DoCheck,AfterContentInit,AfterContentChecked,AfterViewInit,AfterViewChecked,OnDestroy。
钩子函数就是在对应的生命周期前面加上前缀 ng,比如 OnInit,对应的钩子函数是 ngOnInit()。

钩子函数到底是干什么的?是对生命周期中的不同的phrase做出响应的 like: ngOnChanges, ngDoCheck, ngAfterContentChecked…

执行顺序:
在这里插入图片描述

Angular:生命周期和钩子函数


标签:

素材巴巴 Copyright © 2013-2021 http://www.sucaibaba.com/. Some Rights Reserved. 备案号:备案中。