当前位置:  开发笔记 > 前端 > 正文

控制isOpen in angular ui bootstrap

如何解决《控制isOpeninangularuibootstrap》经验,为你挑选了1个好方法。

我想在angualr ui bootstrap accordion指令中使用isOpen属性,这样就可以打开手风琴中第一个ng-repeat的第一个元素.我尝试过一些没有运气的事情.任何人都可以就此提出建议吗?

    //html
          

Step {{$index+1}}: {{value.title}}

Summary: {{value.summary}}
Courses
{{$index+1}}. {{value.title}}

//controller angular .module('neuralquestApp') .controller('AccordionCtrl', AccordionCtrl); function AccordionCtrl(FirebaseUrl, $firebaseObject, $firebaseArray) { var accordionCtrl = this; var getLessons = getLessons; accordionCtrl.oneAtATime = true; accordionCtrl.init = init; accordionCtrl.init(); accordionCtrl.isNotString = isNotString; accordionCtrl.firstIndex = firstIndex; /*====================================== = IMPLEMENTATION = ======================================*/ function init() { getLessons(); } function firstIndex(index) { if(index === 0){ return true; } else { return false; } } function getLessons() { var ref = new Firebase(FirebaseUrl); accordionCtrl.lessons = $firebaseObject(ref.child('NeuralNetwork')); } function isNotString(val) { // console.log('val', val); if(typeof val === "string"){ console.log('is string', val); return false; } else { return true; } } }

Rob J.. 5

is-open属性设置为与控制器进行双向绑定,因此您可以执行以下操作:

{{group.content}}
angular.module('ui.bootstrap.demo').controller('AccordionDemoCtrl', function ($scope) { $scope.openIndex = [true]; $scope.groups = [ { title: 'Group Header - 1', content: 'Group Body - 1' }, { title: 'Group Header - 2', content: 'Group Body - 2' }, { title: 'Group Header - 3', content: 'Group Body - 3' }, { title: 'Group Header - 4', content: 'Group Body - 4' } ]; });

示例plunk.此外,close-others属性的默认值为true,因此您无需将其显式设置为true.



1> Rob J..:

is-open属性设置为与控制器进行双向绑定,因此您可以执行以下操作:

{{group.content}}
angular.module('ui.bootstrap.demo').controller('AccordionDemoCtrl', function ($scope) { $scope.openIndex = [true]; $scope.groups = [ { title: 'Group Header - 1', content: 'Group Body - 1' }, { title: 'Group Header - 2', content: 'Group Body - 2' }, { title: 'Group Header - 3', content: 'Group Body - 3' }, { title: 'Group Header - 4', content: 'Group Body - 4' } ]; });

示例plunk.此外,close-others属性的默认值为true,因此您无需将其显式设置为true.

推荐阅读
跟我搞对象吧
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有