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弹出框的函数openDialog
uiModule.controller("UiController",function($scope,$modal){
//打开dialog的函数
$scope.openDialog = function(){
$modal.open({
templateUrl:"myModalContent.html",//dialog的id,与html建立的template的id一致
controller:"ModalController"//指定dialog的controller
});
};
})
5.定义dialog弹出框的 ModalController
这个controller中声明弹出框中确认和取消按钮的单击事件的处理函数
controller("ModalController",function($scope, $modalInstance){
//定义dialog中的确认按钮的点击事件的处理函数
$scope.ok = function(){
$modalInstance.close();//
};
//定义dialog中的取消按钮的点击事件的处理函数
$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的使用教程,希望对大家有所帮助!
相关文章
学习AngularJs:Directive指令用法(完整版)
这篇文章主要学习AngularJs:Directive指令用法,内容很全面,感兴趣的小伙伴们可以参考一下2016-04-04
AngularJS中controller控制器继承的使用方法
这篇文章主要介绍了AngularJS中controller控制器继承的使用方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2017-11-11
AngularJS学习笔记之基本指令(init、repeat)
AngularJS 指令是扩展的 HTML 属性,带有前缀 ng-。ng-app 指令初始化一个 AngularJS 应用程序。ng-init 指令初始化应用程序数据。ng-model 指令把应用程序数据绑定到 HTML 元素。2015-06-06


最新评论