我希望在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);
}
}
};
}]);