Angularjs中的ui-bootstrap的使用教程
1.新建uiBootstrap.html頁面,引入依賴的js和css類庫
2.新建uiBootstrap.js文件,定義一個uiModule 模塊,引入依賴的模塊
/** * Created by zhong on 2015/9/7. */ var uiModule = angular.module("uiModule",["ui.bootstrap","ui.router"]); });
3.定義dialog彈出窗口的模板
4.定義一個 UiController,并聲明一個用于打開dialog彈出框的函數(shù)openDialog
uiModule.controller("UiController",function($scope,$modal){ //打開dialog的函數(shù) $scope.openDialog = function(){ $modal.open({ templateUrl:"myModalContent.html",//dialog的id,與html建立的template的id一致 controller:"ModalController"http://指定dialog的controller }); }; })
5.定義dialog彈出框的 ModalController
這個controller中聲明彈出框中確認和取消按鈕的單擊事件的處理函數(shù)
controller("ModalController",function($scope, $modalInstance){ //定義dialog中的確認按鈕的點擊事件的處理函數(shù) $scope.ok = function(){ $modalInstance.close();// }; //定義dialog中的取消按鈕的點擊事件的處理函數(shù) $scope.cancel = function(){ $modalInstance.dismiss('cancel'); } });
5.在uiBootstrap.html文件中添加一個按鈕,用于打開窗口
<div ng-controller="UiController"> <button ng-click="openDialog()" class="btn btn-default">打開彈出窗口</button> </div>
6.效果
補充:
以上所述是小編給大家介紹的Angularjs中的ui-bootstrap的使用教程,希望對大家有所幫助!
相關(guān)文章
Angular.js之作用域scope''@'',''='',''&''實例詳解
這篇文章主要介紹了Angular.js之作用域scope'@','=','&'實例詳解,需要的朋友可以參考下2017-02-02AngularJs Using $location詳解及示例代碼
本文主要介紹AngularJs Using $location的知識資料,這里整理了相關(guān)的資料,及簡單示例代碼,有興趣的小伙伴可以參考下2016-09-09Angular依賴注入optional?constructor?parameters概念
這篇文章主要為大家介紹了Angular?依賴注入領(lǐng)域里?optional?constructor?parameters?的概念及使用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-11-11AngularJs Injecting Services Into Controllers詳解
本文主要介紹AngularJs Injecting Services Into Controllers的知識,這里整理了一下相關(guān)資料,及示例代碼,幫助大家學習和理解,有興趣的小伙伴可以參考下2016-09-09angularJs select綁定的model取不到值的解決方法
今天小編就為大家分享一篇angularJs select綁定的model取不到值的解決方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-10-10