I'm having a problem how to solve to implement buttons refresh (enable/disable) without using ng-disabled and ng-click
I've send to my directive the following configuration (one or more buttons)
buttonsConfig() {
var button1 = {
icon: '<i class="fa fa-check"></i>',
name: button,
actionEvent: () => { this.openConfirm(); },
order: 1,
active: false,
large: true
}
}
Here it is how I made dynamically HTML and check the confing file of disabled/enabled button(s)
link: ng.IDirectiveLinkFn = ($scope: IActionBarScope, $element: ng.IAugmentedJQuery, $attrs: ng.IAttributes) => {
var navbar = this.drawActionBar($scope.config);
var padder = angular.element('<div id="padder" ng-if="action.isOpen"></div>');
this.$compile(navbar)($scope);
this.$compile(padder)($scope);
$element.append(navbar, padder);
}
setupButtonActions(element: ng.IAugmentedJQuery, config) {
if (config.actionEvent != null) {
if (config.active === false) { //skip undefined or true
element.addClass("disabled");
} else {
element.removeClass("disabled");
element.mouseup(config.actionEvent);
}
}
}
in my directive I generate html buttons (small/large) on dynamical HTML grid (CSS), so I do not know how to bind that button is enabled/disabled.
Before used my directive I used:
<button ng-if="!ctrl.isReadOnly" type="submit" class="btn btn-flat btn-primary" ng-disabled="!ctrl.selectedAreReady()" ng-click="ctrl.openConfirm()"><i class="fa fa-check"></i> {{'button' | translate}}</button>
and it was all done static in html, without coding, so I sended through the ng-disabled=ctrl.selectedAreReady() that the button is enabled or not.