我的应用程序中有以下代码:
模板:
<ng-container ng-if="cpt < 3">
{{cpt}}
<button pButton type="button" (click)="incrementCpt()" label="+"></button>
</ng-container>组件:
public cpt: number = 0;
...
incrementCpt() {
this.cpt++;
}但这个按钮永远不会被隐藏。我不明白为什么?
发布于 2017-09-14 00:35:40
if应为*ngIf而不是ng-if
发布于 2017-09-14 00:36:03
<button pButton type="button" (click)="incrementCpt().bind(this)" label="+"></button> 你也试过吗?
发布于 2017-09-14 00:42:43
因为您没有在ngIf中使用过*
像这样使用
*ngIf="cpt < 3"https://stackoverflow.com/questions/46202666
复制相似问题