【发布时间】:2016-07-31 20:13:39
【问题描述】:
考虑这个子组件:
@Component({
selector: 'mySelector',
template: `<ion-spinner [ngIf]="ngif"></ion-spinner>`
})
export class MyDirective {
ngif: boolean;
constructor() {}
@Input() serverWaiting:boolean = true;
@HostBinding('ngIf')
ngOnChanges() {
this.ngif = !this.serverWaiting ? true : null;
}
主机组件的模板:
<mySelector [serverWaiting]></mySelector>
主机组件:
@Component({
templateUrl: 'hostComp.html',
directives: [myDirective]
})
export class HostComp {
serverWaiting = true;
}
然而,Spinner 并未显示。知道我做错了什么吗?
来源:https://angular.io/docs/ts/latest/api/common/index/NgIf-directive.html
【问题讨论】:
标签: angular