简体   繁体   English

Angular mobile - 手风琴打开/关闭

[英]Angular mobile - accordion open/close

Hi guys i'm using angular mobile framework and i had implemented the accordion.大家好,我正在使用 angular 移动框架,并且我已经实现了手风琴。 The thing is that by default when you click on it, it opens and if i click the same component again it doesn't close.问题是默认情况下,当您单击它时,它会打开,如果我再次单击同一个组件,它不会关闭。

Here is the online example.这是在线示例。 http://mobileangularui.com/demo/#/accordion . http://mobileangularui.com/demo/#/accordion

What i need is to be able to open it and close it like most of the accordions component.我需要的是能够像大多数手风琴组件一样打开和关闭它。 I tried is.open="" but it did't work.我试过 is.open="" 但它没有用。

It is design to only open, because of this line of code:由于这行代码,它被设计为只打开:

ui-set="{'myAccordion': i}"

So when you click on it again, it just restates that this tab should be open.因此,当您再次单击它时,它只是重申该选项卡应该打开。

What you need to do is check if the item clicked on is already the opened one, and if true, then just set it to some outside value.您需要做的是检查单击的项目是否已经是打开的项目,如果为真,则将其设置为某个外部值。

ui-set="{ 'myAccordion': Ui.get('myAccordion') == item ? -1 : item }"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM