AngularJS show/hide from inside directive.
HTML
<div ng-app="myApp" ng-controller="MainCtrl">
<button ng-click="show('start')">Show start.</button>
<button ng-click="show('finish')">Show finish.</button>
</div>
JavaScript
var app = angular.module('myApp', []);
app.controller('MainCtrl', function($scope) {
$scope.showing = {};
$scope.isShowing = function(id) {
if (!$scope.showing[id]) {
$scope.showing[id] = false;
}
return $scope.showing[id];
};
$scope.show = function(id) {
$scope.showing[id] = true;
};
$scope.toggle = function(id) {
$scope.showing[id] = !$scope.showing[id];
};
});
app.directive('alertMe', function() {
return {
restrict: 'E',
transclude: true,
template: '<button ng-transclude></button>',
link: function postLink(scope, element, attrs) {}
};
});