无法绑定到“已禁用",因为它不是"li"的已知属性 [英] Can't bind to 'disabled' since it isn't a known property of 'li'

查看:72
本文介绍了无法绑定到“已禁用",因为它不是"li"的已知属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在li元素中添加了[disabled]属性.但是我得到这个错误:

I added [disabled] property to li element. But I get this error:

由于它不是'li'的已知属性,因此无法绑定到'disabled'.

这是我的代码部分:

<li [disabled]="pager.currentPage > 1">
</li>

有人可以帮助我吗?

推荐答案

<li>元素没有disabled属性.
您实际上未应用希望应用于<li的组件或指令,或者应该设置了disabled属性而不是属性

The <li> element doesn't have a disabled property.
Either a component or directive that you expect to be applied to <li was actually not applied, or perhaps the disabled attribute should be set instead of the property

<li [attr.disabled]="pager.currentPage > 1 ? true : null">

null用于在条件为false的情况下删除该属性.布尔值false将导致

null is to get the attribute removed in case the condition is false. A boolean false would lead to

<li disabled="false">

这可能不是您想要的.有了null,您将获得

which might not what you want. With null you get

<li>

这篇关于无法绑定到“已禁用",因为它不是"li"的已知属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆