加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular 依赖性注入 changeDetection 可拖拽的属性型指令

发布时间:2020-12-17 08:24:29 所属栏目:安全 来源:网络整理
导读:4.1 依赖性注入 令牌 构建 依赖 Injector Provider Object 难。。 4.2 changeDetection 检查变化的策略:默认:全局检查, 改为onpush策略,减少全局检查的频率,大应用可以以此提高性能 (changeDetection:ChangeDetectionStrategy.OnPush) 然后在constructor

4.1 依赖性注入
令牌 构建 依赖
Injector Provider Object 难。。

4.2 changeDetection
检查变化的策略:默认:全局检查,
改为onpush策略,减少全局检查的频率,大应用可以以此提高性能
(changeDetection:ChangeDetectionStrategy.OnPush)
然后在constructor中申明ChangeDetectorRef,再调用它的markDetector方法

constructor(...,private cd:ChangeDetectorRef )
xx(){
    ...
    this.cd,markForCheck();
}

4.3 指令
指令:组件是一种带模板的指令
指令分为结构型(Structural)指令和属性型(Attribute)指令

Renderer2 和 ElementRef
Angular不提倡直接操作DOM,这是一个危险的行为
对于DOM的操作应该通过Renderer2来进行,ElementRef可以理解为指向DOM元素的引用

drag-drop 拖拽 Can't bind to 'app-draggable' since it isn't a known property of 'mat-list-item'. 1. If 'mat-list-item' is an Angular component and it has 'app-draggable' input,then verify that it is part of this module. 2. If 'mat-list-item' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. (" 'priority-emergency':item.priority===1 }" [ERROR ->][app-draggable]="true" [draggedClass]="drag-start" (click)="onItemClick()" "): ng:///TaskModule/TaskItemComponent.html@7:2 --->莫名其妙 多保存几次就好了 [app-draggable]="true" [draggedClass]="'drag-start'" 不加''会认为是成员变量,找不到就是undefined

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读