'ngIf' は 'div' の既知のプロパティではないため、バインドできません。
要素は<div [ngIf]="isAuth" id="sidebar">
コンポーネントは次のとおりです。
import SessionService from '../session/session.service';
import { Component } from '@angular/core';
@Component({
providers: [],
selector: 'navbar-left',
styles: [require('./navbar-left.scss')],
template: require('./navbar-left.html'),
})
export default class NavbarLeftComponent {
public isAuth: boolean = false;
constructor(private sessionService: SessionService) {
this.isAuth = sessionService.sessionIsAuth();
}
}
正確に何が間違っているのか分かりません。これは子コンポーネントです。親コンポーネント、つまりアプリコンポーネントではngIf
正常に動作します。Angular RC5
ベストアンサー1
RC5 を使用している場合は、これをインポートします。
import { CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
CommonModule
コンポーネントを提供しているモジュールから必ずインポートしてください。
@NgModule({
imports: [CommonModule],
declarations: [MyComponent]
...
})
class MyComponentModule {}