Js:
varMymodal = Angular.module ('Mymodal', []); Mymodal.controller ('Mainctrl', Function ($scope) {$scope. ShowModal=false; $scope. Togglemodal=function () {$scope. ShowModal= !$scope. ShowModal; }; }); Mymodal.directive ('modal', function () {return{Template:'<div class= "Modal Fade" >'+'<div class= "Modal-dialog" >'+'<div class= "Modal-content" >'+'<div class= "Modal-header" >'+'<button type= "button" class= "Close" data-dismiss= "modal" aria-hidden= "true" >×</button> '+''+'</div>'+'<div class= "Modal-body" ng-transclude></div>'+'</div>'+'</div>'+'</div>', restrict:'E', transclude:true, replace:true, Scope:true, link:function postlink (scope, element, attrs) {Scope.title=Attrs.title; Scope. $watch (attrs.visible, function (value) {if(Value = =true) $ (Element). Modal ('Show'); Else$ (Element). Modal ('Hide'); }); $ (Element). On ('Shown.bs.modal', function () {scope. $apply (function () {scope. $parent [attrs.visible]=true; }); }); $ (Element). On ('Hidden.bs.modal', function () {scope. $apply (function () {scope. $parent [attrs.visible]=false; }); }); } }; });
AngularJs + Bootstrap