0
我正在嘗試使用angularjs指令創建自定義twitter引導模式彈出。我的問題是如何從任何控制器angularjs自定義twitter bootstrap模態指令
<!-- 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>
控制彈出和控制器指令是
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");
});
}
}
});
,這是我怎麼也叫來自初始頁面的指令
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: '/'
});
});
我如何控制HTML中的模態彈出菜單 我喜歡這樣。
<div login-modal></div>
我想定製這種模式到我的需要。就像我想要控制顯示的文本一樣。添加新元素並在特定條件下調用此彈出菜單/顯示從控制器中滿足。