不能绑定到'ngIf‘,因为它不是'div’的已知属性。
它的组件是:
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
发布于 2016-08-21 03:45:45
如果您使用的是RC5,则导入以下内容:
import { CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
并确保从提供组件的模块导入CommonModule
。
@NgModule({
imports: [CommonModule],
declarations: [MyComponent]
...
})
class MyComponentModule {}
发布于 2016-11-14 17:16:54
对于那些仍然有问题的人,我也有一个问题,我输入的是ngif
而不是ngIf
(注意大写的'I')。
发布于 2016-08-22 02:05:16
你应该使用*ngIf而不是ngIf:
<div *ngIf="isAuth" id="sidebar">
https://stackoverflow.com/questions/39058075
复制相似问题