如何使定制的面板始终打开角形自举手风琴

时间:2015-08-18 14:05:46

标签: angularjs

有没有办法让一个手风琴面板始终打开。我创建自定义指令,它在bootstrap-tpls中覆盖一个并且工作正常。遵循指令:

.directive('myAccordionGroup', function () {
        return {
            require: '^myAccordion', // We need this directive to be inside an accordion
            restrict: 'EA',
            transclude: true, // It transcludes the contents of the directive into the template
            replace: true, // The element containing the directive will be replaced with the template
            templateUrl: function (element, attrs) {
                return attrs.templateUrl || './template/accordion/accordion-group.html';
            },
            scope: {
                viewlink: '@', // Interpolate the viewlink attribute onto this scope
                heading: '@', // Interpolate the heading attribute onto this scope
                isOpen: '=?',
                isDisabled: '=?'
            },
            controller: function () {
                this.setHeading = function (element) {
                    this.heading = element;
                };
            },
            link: function (scope, element, attrs, accordionCtrl) {
                accordionCtrl.addGroup(scope);

                scope.$watch('isOpen', function (value) {
                    if (value) {
                        accordionCtrl.closeOthers(scope);
                    }
                });

                scope.toggleOpen = function () {
                    if (!scope.isDisabled) {
                        scope.isOpen = !scope.isOpen;
                    }
                };
            }
        };
    })

1 个答案:

答案 0 :(得分:0)

我认为这会奏效:

scope.toggleOpen = function () {
     if (!scope.isDisabled && scope.isOpen === false) {
          scope.isOpen = !scope.isOpen;
     }
};