Bootstrap和Angularjs配合自制彈框的實例代碼
更新時間:2016年08月24日 11:15:05 作者:haiziguo
今天小編通過本文給大家分享Bootstrap和Angularjs配合自制彈框的實例代碼,代碼簡單易懂,有需要的朋友跟著小編一起學習
指令
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配合自制彈框,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
詳解Angular中實現(xiàn)自定義組件的雙向綁定的兩種方法
這篇文章主要介紹了詳解Angular中實現(xiàn)自定義組件的雙向綁定的兩種方法,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2018-11-11全面解析Angular中$Apply()及$Digest()的區(qū)別
$apply()和$digest()在AngularJS中是兩個核心概念,但是有時候它們又讓人困惑。這篇文章主要介紹了Angular中$Apply()及$Digest()區(qū)別詳細說明的相關(guān)資料,需要的朋友可以參考下2016-08-08Angular.js中ng-include用法及多標簽頁面的實現(xiàn)方式詳解
這篇文章主要給大家介紹了在Angular.js中ng-include用法及多標簽頁面的實現(xiàn)方式的相關(guān)資料,文中通過示例代碼介紹的非常詳細,相信對大家具有一定的參考學習價值,需要的朋友們下面隨著小編一起來學習學習吧。2017-05-05Angular搜索 過濾 批量刪除 添加 表單驗證功能集錦(實例代碼)
這篇文章主要介紹了Angular搜索 過濾 批量刪除 添加 表單驗證功能集錦(實例代碼),需要的朋友可以參考下2017-10-10AngularJS實現(xiàn)的獲取焦點及失去焦點時的表單驗證功能示例
這篇文章主要介紹了AngularJS實現(xiàn)的獲取焦點及失去焦點時的表單驗證功能,涉及AngularJS使用ng-blur、ng-focus針對表單事件監(jiān)聽相關(guān)操作技巧,需要的朋友可以參考下2017-10-10