![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Angular
文章平均质量分 51
zsy_1991
这个作者很懒,什么都没留下…
展开
-
重试的代码片段
angular 中重试常用的代码片段原创 2022-06-10 21:37:42 · 140 阅读 · 0 评论 -
When Observable completes without emitting, toPromise() will successfully resolve with undefined.
When Observable completes without emitting, toPromise() will successfully resolve with undefined.原创 2022-06-10 14:21:55 · 108 阅读 · 0 评论 -
source observable 发生错误之后会直接进入到catchError operator 而不是按照pipe里面的顺序处理之后再进入catchError
catchError 使用笔记原创 2022-06-08 15:06:46 · 156 阅读 · 0 评论 -
【Question】rxjs/operator takeWhile vs takeUntil
讨论takeWhile 和 takeUntil 使用场景,求解为什么有些场景下takeWhile 失效原创 2022-06-07 21:49:41 · 157 阅读 · 0 评论 -
【Question】为什么angular component 使用内置的pipe 需要注入
内置pipe 在component中使用为何需要再次注入原创 2022-06-06 14:28:15 · 182 阅读 · 0 评论 -
【未解决】angular nebular toastrService.show can‘t trigger
问题解决:待排查问题描述:想要做一个全局拦截器,用来针对所有出错的http 请求,通知用户出错且显示出错提示。主要代码如下,只要错误是401,弹框不能成功触发。if (error?.status === 401) { this.toastrService.show(message, title); // 期望有弹框提示,但是没有 this.router.navigate(['/login']);} else if (error?.status >= 500) { this.to原创 2022-05-25 15:03:04 · 151 阅读 · 0 评论 -
angular http interceptor 使用笔记
interceptor 在app.modulte.ts 中的provides中,...providers: [ { provide: HTTP_INTERCEPTORS, useClass: CustomizeInterceptor, multi: true}, ],....interceptor 内容,...@Injectable()export class CustomizeInterceptor implements HttpInterceptor { constru原创 2022-05-24 22:30:36 · 299 阅读 · 0 评论 -
【Question】what‘s the scenario of aliasing a class interface
官网的这部分内容理解不了什么意思,先放在这里!!!Aliasing a class interfaceGenerally, writing variations of the same parent alias provider uses forwardRef as follows.# dependency-injection-in-action/src/app/parent-finder.component.tsproviders: [{ provide: Parent, useExisting原创 2022-05-23 16:44:13 · 147 阅读 · 0 评论 -
angular library执行ng build libName 时报错:ERROR: Unable to write a reference to SpaceComponent in ...
问题解决:对于monorepo 情况下不能使用ng build <libName>, 应该使用ngx ngc -p projects/<libName>/tsconfig.lib.json, 执行成功后可以在outDir下看到生成的library 编译之后的文件。问题描述:本地是一个monorepo 的项目,其中有一个组件需要共享,所以想到了angular library 方式,但是library 里面又使用了公用的资源shared.module,这些资源是在这个library原创 2022-05-05 21:52:46 · 306 阅读 · 0 评论 -
angular empty patch can not redirect correctly
问题解决通过调换app.module.ts 中import 的 UsersModule.forRoot()和AppRoutingModule顺序解决问题。原因是angular 的路由一旦匹配到路径将不再继续往下匹配。UsersModule 提供了UserService, 期望是一个单例,所以在module中提供了一个forRoot 方法, 同时在Angular官网的Router tutorial: tour of heroes 中看到app-routing.module.ts 最好在最后面引入,因为对于急原创 2022-05-05 21:50:44 · 133 阅读 · 0 评论 -
ng test 运行报错SassError: Can‘t find stylesheet to import, 导致case 一个都没有执行
问题解决在angular.json 中test target中也配置和build target 一样的stylePreprocessorOptions.includePaths , 问题解决。在调查此问题的时候发现很多回答需要配置karma.config.js 在里面加files 和 preprocessors ,从而引入样式文件和预处理引擎,此种都是不必要的。问题描述ng start, ng build 项目都可以正常运行,但是执行ng test 就会报错,从而导致case不运行,报错信息如下:原创 2022-04-22 13:27:27 · 15083 阅读 · 0 评论 -
nebular 引入iconfont 字体图标,图标渲染成了框框
问题描述angular 项目,需要引入字体图标,在项目初始化的时候注册了字体,如下:this.iconLibrary.registerFontPack('iconfont', { iconClassPrefix: 'icon' });使用nb-icon 调用字体图标,如下:<nb-icon icon="" pack="iconfont"></nb-icon><span>控制面板</span>结果渲染成了框框,说明字体识别不出来。问题解决其原创 2022-04-13 21:35:58 · 636 阅读 · 0 评论 -
如何在angular 项目中设置scss 的load path,简化相对路径引用问题
问题解决angular 项目中样式互相引用,烦人的无休止的相对路径引用问题项目结构如下:// your folder structure- src - app - app.component.ts - hello - hello.component.html - hello.component.scss - hello.component.ts - ... - stylings - _variables.scss样式文件引入全局样式// hello原创 2022-04-11 15:58:43 · 1304 阅读 · 0 评论 -
配置providedIn: ‘root‘ 的angular service 不一定在整个application 层面就是单例服务
There are two ways to make a service a singleton in Angular:Set the providedIn property of the @Injectable() to “root”.Include the service in the AppModule or in a module that is only imported by the AppModule以上是Angular 官网上的原话,说是有两种方法在Angular 应用中提供单例服原创 2022-04-02 17:22:36 · 1950 阅读 · 0 评论