How can I change the value of no-lines
property dynamically in Ionic?
I have tried:
<ion-item [no-lines]='condition'> test </ion-item>
This gives me an error:
Error: Template parse errors: Can't bind to 'no-lines' since it isn't a known property of 'ion-item'. 1. If 'ion-item' is an Angular component and it has 'no-lines' input, then verify that it is part of this module. 2. If 'ion-item' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("/div>
<ion-item [attr.no-lines]='condition'> test </ion-item>
You need [attr.no-lines]
instead of no-lines
. Also, it's worth noting if you want lines to appear, you need the expression to evaluate to null
not false
.
<ion-header>
<ion-navbar>
<ion-title>{{ appName }} 3.4.0</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-item>
Item 1
</ion-item>
<ion-item no-lines>
Item 2
</ion-item>
<ion-item [attr.no-lines]="null">
Item 3
</ion-item>
<ion-item [attr.no-lines]="true">
Item 4
</ion-item>
<ion-item [attr.no-lines]="false">
Item 5
</ion-item>
</ion-content>
Items 1 and 3 above have lines and items 2, 4, and 5 do not.
您可以使用以下方法向元素添加其他属性:
<div [attr.no-lines]='yourExpression'></div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.