欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Bootstrap和Angularjs配合自制弹框的实例代码

程序员文章站 2023-11-18 15:14:58
指令 directive('bspopup', function ($parse) { return { require: 'ngmodel', restr...

指令

directive('bspopup', function ($parse) {
return {
require: 'ngmodel',
restrict: 'a',
link: function (scope, elem, attrs, ctrl) {
scope.$watch(function () {
return $parse(ctrl.$modelvalue)(scope);
}, function (newvalue) {
if (newvalue ==0) {
$(elem).modal('hide');
return;
}
if (newvalue == 1) {
$(elem).modal('show');
return;
}
});
}
}
});
<button class="btn btn-xs btn-warning" data-target="#mymodal" data-toggle="modal" ng-click="sss()">弹框</button>
<div aria-hidden="true" aria-labelledby="mymodallabel" role="dialog" tabindex="-1" class="modal fade" bs-popup="" ng-model="test"
id="mymodal" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header alert-info">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
<h4 id="mymodallabel" class="modal-title">弹框</h4>
</div>
<div class="modal-body">
<button class="btn btn-info" ng-click="hhh()">测试</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>

以上所述是小编给大家介绍的bootstrap和angularjs配合自制弹框,希望对大家有所帮助