I have created a Hybrid app using ngUpgrade and am currently going through my directives upgrading them to Angular components.
I have ran into this issue and cannot seem to fix it
Can't bind to 'ngif' since it isn't a known property of 'span'
Most answers on SO say to include CommonModule
or BrowserModule
within the parent Module, and whilst this worked for other components I have upgraded, it curiously hasnt worked for this one
Note if I remove *ngIf
the component renders correctly, it only fails when I try to use *ngIf
Here is my module definition
import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core";
import { DashboardBoxSmallComponent } from "./dashboard/dashboardBoxSmall.component";
import { MiscDirectivesModule } from "./_misc/_misc.directives.module";
import { VehicleDirectivesModule } from "./_vehicle/_vehicle.directives.module";
@NgModule({
imports: [
CommonModule,
MiscDirectivesModule,
VehicleDirectivesModule
],
entryComponents: [
DashboardBoxSmallComponent
],
declarations: [
DashboardBoxSmallComponent
]
})
export class DirectivesModule {
constructor() {
}
}
The component.ts itself
import { Component, Input } from "@angular/core";
import "./dashboardBoxSmall.component.scss";
@Component({
selector: "dashboard-box-small",
template: require("./dashboardBoxSmall.component.html")
})
export class DashboardBoxSmallComponent {
@Input() boxIcon: string;
@Input() boxIconClass: string;
@Input() boxTitle: string;
@Input() boxSubtitle: string;
// ---
constructor() {
}
}
The HTML
<div class="ml-10 layout-column overflow-hidden">
<div class="bold font-size-14">
<ng-content></ng-content>
<span *ngIf="boxTitle">{{boxTitle}}</span>
</div>
<div class="text-muted font-size-11">{{boxSubtitle}}</div>
</div>