rxjs的几点使用心得
摘要:1.对错误的处理 日常使用中,点击按钮需要往后台发消息,为了不重复发消息,经常需要把点击事件做成subject,然后把发消息的过程做成switchMap,类似下面的写法 const subject = new rxjs.Subject(); subject.pipe( rxjs.operators.
阅读全文
posted @
2023-04-10 16:02
chen8840
阅读(384)
推荐(0)
angular好文
摘要:Angular常见问题:subscribe()还是 async 管道 ? 终极答案就在这里 Angular Development #10 – RouteReuseStrategy – Maintaining Component State on Navigation Angular Develop
阅读全文
posted @
2022-03-25 17:20
chen8840
阅读(54)
推荐(0)
angular变化检测OnPush策略需要注意的几个问题
摘要:OnPush组件内部触发的事件(包括viewChild)会引起组件的一次markForCheck Detached组件内部触发的事件不会引起组件的变化检测 OnPush组件的contentChild依然会在变化检测周期时进行自身的变化检测 OnPush进行markForCheck时,会以此对父组件进
阅读全文
posted @
2021-03-11 22:20
chen8840
阅读(203)
推荐(0)
angular变更检测相关文章
摘要:你需要了解的关于Angular 变更检测的一切 If you think `ngDoCheck` means your component is being checked — read this article (如果你认为 `ngDoCheck`意味着组件正被检测, 那么阅读这篇文章) He w
阅读全文
posted @
2021-03-03 14:15
chen8840
阅读(45)
推荐(0)
一步一步在angular11中添加多语言支持
摘要:1.新建angular 2.添加@angular/localize ng add @angular/localize 3.设置默认locale_id,在app.module.ts中(忽略此步) import { NgModule } from '@angular/core'; import { Br
阅读全文
posted @
2021-01-28 12:40
chen8840
阅读(899)
推荐(0)
使用Pure Pipes来替换HTML里面的纯函数
摘要:<ul *ngFor="let item of list"> <li>{{show(item.label)}}</li> </ul> 上面的代码每次变化检测的周期都会执行,即使item.label没有改变 此时应该使用Pure Pipes来代替show函数 @Pipe({ name: 'showla
阅读全文
posted @
2021-01-25 16:15
chen8840
阅读(90)
推荐(0)
使用OnPush和immutable.js来提升angular的性能
摘要:angular里面变化检测是非常频繁的发生的,如果你像下面这样写代码 <div> {{hello()}} </div> 则每次变化检测都会执行hello函数,如果hello函数十分耗时,则会出现占用CPU高的问题。 这时,推荐使用OnPush策略和immutable.js来提升angular应用的性
阅读全文
posted @
2021-01-20 17:05
chen8840
阅读(277)
推荐(0)
ExpressionChangedAfterItHasBeenCheckedError详细解释
摘要:一个angular组件,他的生命周期是这样的 update bound properties for all child components/directives call ngOnInit, OnChanges and ngDoCheck lifecycle hooks on all child
阅读全文
posted @
2021-01-14 12:01
chen8840
阅读(1805)
推荐(0)
angular里forwardRef的原理
摘要:一段会报错的angular代码 @Injectable() class Socket { constructor(private buffer: Buffer) { } } console.log(Buffer); // undefined @Injectable() class Buffer {
阅读全文
posted @
2020-12-10 12:43
chen8840
阅读(380)
推荐(0)
What's the difference between markForCheck() and detectChanges()
摘要:https://stackoverflow.com/questions/41364386/whats-the-difference-between-markforcheck-and-detectchanges
阅读全文
posted @
2019-03-21 17:49
chen8840
阅读(385)
推荐(0)
angular中ngOnChanges与组件变化检测的关系
摘要:1.ngOnChanges只有在输入值改变的时候才会触发,如果输入值(@Input)是一个对象,改变对象内的属性的话是不会触发ngOnChanges的。 2.组件的变化检测: 2a.changeDetection如果是ChangeDetectionStrategy.Default的话,无论输入值(@
阅读全文
posted @
2019-03-21 15:32
chen8840
阅读(5576)
推荐(0)
angular里forRoot的作用
摘要:模块A是这样定义的 如果有惰性模块lazyModule导入模块A,那么会生成子注入器将AService重新生成 这时如果想将AService变成全局唯一的,那么在lazyModule导入的时候就不要导入providers而只导入TitleComponent forRoot这时就有用武之地了 改写A
阅读全文
posted @
2018-08-21 14:44
chen8840
阅读(5318)
推荐(4)
angular2 里父子组件传值的坑
摘要:1.如果传的是基本类型的值,子组件里改变该值,父组件无变化 2.如果传的是对象,子组件里改变对象里的变量,父组件会变化 3.如果传的是函数,this不会继续指向父组件对象了,如果需要this指向父组件,需要使用bind绑定
阅读全文
posted @
2018-05-25 10:00
chen8840
阅读(323)
推荐(0)