小编bil*_*sau的帖子

运算符“>”无法应用于类型“字符串”和“数字”错误

我在组件 HTML 文件中以角度方式使用此代码。但是当 ng 服务时,会显示错误

运算符“>”不能应用于类型“字符串”和“数字”

如何解决这个问题

我的角度 html 代码是

<input type="text" #age (keyup)="0" />

<div *ngIf="age.value>18 ; else elseblock">
    You are elegable for vote
</div>

<ng-template #elseblock>
    <div>You are not elegable for vote</div>
</ng-template>
Run Code Online (Sandbox Code Playgroud)

错误是

错误:src/app/app.component.html:88:17 - 错误 TS2365:运算符“>”无法应用于类型“字符串”和“数字”。

88 <div *ngIf="age.value>18 ; else elseblock"> ~~~~~~~~~~~~

src/app/app.component.ts:9:16 9 templateUrl: './app.component.html', ~~~~~~~~~~~~~~~~~~~~~~ 发生错误在组件 AppComponent 的模板中。

angular angular10

1
推荐指数
1
解决办法
9764
查看次数

标签 统计

angular ×1

angular10 ×1