I tried to make a simple component in Ionic3 to display dots to indicate on which page we are. I'd used the ionic generate command to generate this component :
import { Component, Input } from '@angular/core';
@Component({
selector: 'panel-indicator',
templateUrl: 'panel-indicator.html'
})
export class PanelIndicatorComponent {
@Input() page: number;
constructor() {
console.log('Hello PanelIndicatorComponent Component');
this.page = 1;
}
}
and this is the template part :
<div class="indicator-list">
<div class="indicator selected" [ngClass]="{'selected': page === 1}"></div>
<div class="indicator" [ngClass]="{'selected': page === 2}"></div>
<div class="indicator" [ngClass]="{'selected': page === 3}"></div>
</div>
when i remove ngclass attribute, there is no problems. but, when i add it, i have the following error :
Can't bind to 'ngClass' since it isn't a known property of 'div'. ("
<div class="indicator-list">
<div class="indicator selected" [ERROR ->][ngClass]="{'selected': page === 1}"></div>
<div class="indicator" [ngClass]="{'selected': page =="): ng:///ComponentsModule/PanelIndicatorComponent.html@4:34
Can't bind to 'ngClass' since it isn't a known property of 'div'. ("iv class="indicator selected" [ngClass]="{'selected': page === 1}"></div>
<div class="indicator" [ERROR ->][ngClass]="{'selected': page === 2}"></div>
<div class="indicator" [ngClass]="{'selected': page =="): ng:///ComponentsModule/PanelIndicatorComponent.html@6:25
Can't bind to 'ngClass' since it isn't a known property of 'div'. ("
<div class="indicator" [ngClass]="{'selected': page === 2}"></div>
<div class="indicator" [ERROR ->][ngClass]="{'selected': page === 3}"></div>
</div>
"): ng:///ComponentsModule/PanelIndicatorComponent.html@8:25
at syntaxError (http://localhost:8100/build/vendor.js:101030:34)
at TemplateParser.parse (http://localhost:8100/build/vendor.js:124893:19)
at JitCompiler._parseTemplate (http://localhost:8100/build/vendor.js:134321:37)
at JitCompiler._compileTemplate (http://localhost:8100/build/vendor.js:134296:23)
at http://localhost:8100/build/vendor.js:134198:62
at Set.forEach (<anonymous>)
at JitCompiler._compileComponents (http://localhost:8100/build/vendor.js:134198:19)
at http://localhost:8100/build/vendor.js:134068:19
at Object.then (http://localhost:8100/build/vendor.js:101019:77)
at JitCompiler._compileModuleAndComponents (http://localhost:8100/build/vendor.js:134067:26)
i haven't find anything about this issue. So, if you have an idea, you're welcome.
thanks for reading.
You need to add BrowserModule
@NgModule(
imports: [BrowserModule, /* other imports */] from '@angular/platform-browser',
...
)
If it is in a child module import CommonModule.
import { CommonModule } from "@angular/common"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.