【发布时间】:2020-04-29 14:52:03
【问题描述】:
我使用的是 Angular 版本 7.3.7。我创建了一个指令,但它不能正常工作。指令示例:
import { Directive, OnInit } from '@angular/core';
@Directive({
selector: '[matchHeight]'
})
export class MatchHeightDirective implements OnInit {
constructor() { }
ngOnInit() {
console.log("this will be work", "color: red");
}
}
并在shared.module.ts 上导入我的指令。
import { MatchHeightDirective } from './directives/match-height.directive';
const pipes = [DateFormatPipe, SecondToTime, HighlightSearch, TimeFormatPipe];
const components = [
MatchHeightDirective,
];
@NgModule({
declarations: [pipes, components],
imports: [
CommonModule,
],
providers: [DraggableService],
exports: [
CommonModule,
components,
],
})
export class QmsSharedModule {}
并像这样使用它:
<div class="row" matchHeight></div>
但结果没有任何效果。我究竟做错了什么 ?对此有何建议?
【问题讨论】:
标签: angular typescript