当ng-show处于活动状态时,禁用我的按钮

时间:2014-11-28 15:05:48

标签: angularjs

我希望在list-of-items处于有效状态时ng-show停用我的按钮

HTML:

<div class="row" ng-show="platform">
    <div class="col-md-12">
        <div class="bg-light">
            <h3>BRIQUES APPLICATIVES COMMUNES</h3>
            <list-of-items items="application.units"
                           label="$item.name"
                           selected-item="unit"
                           selectable="true"
                           onedit="on_edit_unit($item)"
                           editable="false"
                           size="small">
            </list-of-items>
        </div>
    </div>
</div>
<div class="row" ng-show="unit">
..
</div>

JS:

 $scope.on_edit_unit = function (unit) {
...
}

列表-的项:

var components = angular.module('xxxx.components', []);

components.directive('listOfItems', ['$parse', function ($parse) {

    return {
        restrict: 'E',
        scope: {
            items: '=',
            selectedItem: '=',
            selectable: '=',
            editable: '='
        },
        templateUrl: 'shared/list-of-items.html',
        link: function (scope, element, attrs) {

            scope.typeahead = attrs.typeaheadexpression;
            if (!_.isUndefined(scope.typeahead)) {
                scope.type = 'search';
            }
            scope.size = attrs.size;
            scope.input = {};

            scope.selfLabel = function (item) {
                return $parse(attrs.label)(scope.$parent, {$item: item});
            };

            scope.selfEdit = function (item) {
                if(scope.selectable){
                    $parse(attrs.onedit)(scope.$parent, {$item: item});
                    scope.selectedItem = item;
                }
            };

            scope.selfDelete = function (item) {
                scope.selectedItem = undefined;
                $parse(attrs.ondelete)(scope.$parent, {$item: item});
            };

            scope.selfAdd = function (name) {
                if (name) {
                    $parse(attrs.createfunction)(scope.$parent, {$name: name});
                    scope.resetAndHideInput();
                }
            };

            scope.resetAndHideInput = function () {
                scope.show_input = false;
                scope.input.inputText = '';
            }

            scope.showInput = function () {
                scope.show_input = true;
                window.setTimeout(function () {
                    $('#nameInput').focus();
                }, 80);
            }

        }
    };

}]);

0 个答案:

没有答案