i am trying to create a custom twitter bootstrap modal popup using angularjs Directives. my problem is how can i control the popup from any controller
<!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Hello Modal</h4> </div> <div class="modal-body"> <p>Modal PopUp</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div>
and the controller directive is
var modal = angular.module('directiveModal', ['ngRoute','ngAnimate']);
modal.directive('loginModal', function() {
return {
restrict: 'EA',
templateUrl: 'directiveTemplate/modal.html',
link: function(scope,elem,attr)
{
elem.bind("click",function()
{
console.log("Opening Modal");
});
}
}
});
and this is how i have called directive from the init page
var app = angular.module('myApp', ['ngRoute','ngAnimate','directiveModal']);
app.config(function($routeProvider)
{
$routeProvider
.when("/",{
templateUrl : "template/landing.html",
controller : "landingCtrl"
})
.when("/home",{
templateUrl : "template/home.html",
controller : "homeCtrl"
})
.when("/post",{
templateUrl : "template/post.html",
controller : "postCtrl"
})
.otherwise(
{
redirectTo: '/'
});
});
How can i control the modal popup in html i have it like this.
<div login-modal></div>
I would like to customize this modal to my need. like if i want have control what text to display. add new elements and call this popup/show on certain conditions are met from the controllers.