Angularjs中的ui-bootstrap的使用教程

(编辑:jimmy 日期: 2025/9/27 浏览:2)

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中的ui-bootstrap的使用教程

以上所述是小编给大家介绍的Angularjs中的ui-bootstrap的使用教程,希望对大家有所帮助!

一句话新闻
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。