开发个公共组件,在组件中使用指令一直报错。
template: `
<div class="content-text-bgp">
<div class="content-text" *ngIf="sort" [ngStyle]="{'width': minWidth+'px'}">
<div *ngFor="let item of sort; let i = index"
[ngClass]="{'content-text-title' : true,
'content-text-title-sort': i > 0}">
<div style="float: left">{{item.title}}</div>
<div style="float: left; margin-left: 2em;">
<span><img src="assets/img/smallCard/{{item.sort}}.png" class="sort-content-up"></span>
<span style="padding-left: 0.5em">{{item.value}}</span>
</div>
</div>
</div>
<div class="content-text" *ngIf="!sort" [ngStyle]="{'width': minWidth+'px'}">
<div class="content-text-title">{{title}}</div>
<div class="content-text-content">{{this.util.toThousands(value, null)}}</div>
</div>
</div>
`,
angular的指令模块BrowserModule CommonModule 未导入。
在app.module.ts中导入BrowserModule
import {BrowserModule} from '@angular/platform-browser';
@NgModule({
declarations: [
],
imports: [
BrowserModule,
],
providers: [
],
bootstrap: [AppComponent]
})
在你需要使用的模块中导入CommonModule
import { NgModule } from '@angular/core';
import { D3WidgetComponent } from './d3.widget';
import { SamllCardComponent } from './small.card';
import { CommonModule } from '@angular/common';
export const SCHEMA_THIRDS_COMPONENTS = [
D3WidgetComponent,
SamllCardComponent,
];
@NgModule({
declarations: SCHEMA_THIRDS_COMPONENTS,
entryComponents: SCHEMA_THIRDS_COMPONENTS,
imports: [CommonModule],
exports: [...SCHEMA_THIRDS_COMPONENTS],
})
export class JsonSchemaModule {}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)