然后在Angular4中不是有效的属性名称

时间:2017-09-11 07:11:53

标签: angular

在角度4中我正在使用html代码

<div *ngIf="s.flow";then Avail else NotAvail></div>
<ng-template #Avail><td>{{s.flow.oo_status.status_info}}</td></ng-template>
<ng-template #NotAvail><td>Will Update</td></ng-template>

我的错误

DOMException {message: "Failed to execute 'setAttribute' on 'Element': ';then' is not a valid attribute name.", name: "InvalidCharacterError", code: 5, stack: "Error: Failed to execute 'setAttribute' on 'Elemen…10.144.100.162:3000/polyfills.bundle.js:16036:38)", ngDebugContext: DebugContext_…}

2 个答案:

答案 0 :(得分:1)

<div *ngIf="s.flow;then Avail else NotAvail"></div>
<ng-template #Avail><td>{{s.flow.oo_status.status_info}}</td></ng-template>
<ng-template #NotAvail><td>Will Update</td></ng-template>

应该是*ngIf="s.flow;then Avail else NotAvail"而不是*ngIf="s.flow;"then Avail else NotAvail

答案 1 :(得分:0)

ngIf语法应该在双引号内。你在条件完成之前关闭它。

答案

*ngIf="s.flow;then Avail else NotAvail"

不喜欢这个

*ngIf="s.flow;"then Avail else NotAvail