简体   繁体   English

ng-if内ng-repeat无法正常工作

[英]ng-if inside ng-repeat not working as expected

I have a repeater that I'm using to return views into an accordion. 我有一个中继器,用于将视图返回到手风琴中。 I'd like to conditionally load the views, so I'm wanting to add an ng-if condition on the repeaters elements to check and see if current == true but it's not working. 我想有条件地加载视图,因此我想在Repeaters元素上添加ng-if条件,以检查并查看current == true,但它不起作用。 I'm using Angular 1.0.8. 我正在使用Angular 1.0.8。

I have a fiddle 我有一个小提琴

<div data-ng-view></div> is showing all the same view

Edit: 编辑:

Angular 1.0.8 does not support ng-if so I went with the switch statement. Angular 1.0.8不支持ng-if,所以我使用了switch语句。

       <div ng-switch="group.current">
            <div ng-switch-when="true">
                <div data-ng-view></div>
            </div>
        </div>

Problem was at 问题出在

<div ng-if="group.current == 'true'"><div data-ng-view></div></div>

replaced with 替换为

<div ng-if="group.current === true"><div data-ng-view></div></div>

check updated at http://jsfiddle.net/rajumjib/GUwSh/15/ 检查更新于http://jsfiddle.net/rajumjib/GUwSh/15/

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

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