JSFiddle - React, Tailwind, and code Playground
by jmcooper
HTML
<div ng-app="myModule" ng-controller="myController">
<input ng-model="showIt"></input>
<button ng-hide="hideButton()" confirm="Are you sure?" confirm-action="doIt()">Do It</button>
</div>
JavaScript
var myModule = angular.module('myModule', []);
myModule
.directive('confirm', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.bind('click', function (e) {
if (confirm(attrs.confirm)) {
attrs.confirmAction();
}
});
}
};
})
.controller('myController', function($scope) {
$scope.doIt = function() { alert('did it!'); };
$scope.hideButton = function() { return $scope.showIt == "yes"; }
});