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

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值