<link rel="stylesheet" href="//apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular-ui-bootstrap/1.1.2/ui-bootstrap-tpls.js"></script>
<div ng-controller="AccordionDemoCtrl">
<script type="text/ng-template" id="group-template.html">
<div class="panel {{panelClass || 'panel-default'}}">
<div class="panel-heading">
<h4 class="panel-title" style="color:#fa39c3">
<a href tabindex="0" class="accordion-toggle" ng-click="toggleOpen()" uib-accordion-transclude="heading"><span
ng-class="{'text-muted': isDisabled}">{{heading}}</span></a>
</h4>
</div>
<div class="panel-collapse collapse" uib-collapse="!isOpen">
<div class="panel-body" style="text-align: right" ng-transclude></div>
</div>
</div>
</script>
<p>
<button type="button" class="btn btn-default btn-sm" ng-click="status.open = !status.open">Toggle last panel</button>
<button type="button" class="btn btn-default btn-sm" ng-click="status.isFirstDisabled = ! status.isFirstDisabled">Enable / Disable first panel</button>
</p>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="oneAtATime">
Open only one at a time
</label>
</div>
<uib-accordion close-others="oneAtATime">
<uib-accordion-group heading="Static Header, initially expanded" is-open="status.isFirstOpen" is-disabled="status.isFirstDisabled">
This content is straight in the template.
</uib-accordion-group>
<uib-accordion-group heading="{{group.title}}" ng-repeat="group in groups">
{{group.content}}
</uib-accordion-group>
<uib-accordion-group heading="Dynamic Body Content">
<p>The body of the uib-accordion group grows to fit the contents</p>
<button type="button" class="btn btn-default btn-sm" ng-click="addItem()">Add Item</button>
<div ng-repeat="item in items">{{item}}</div>
</uib-accordion-group>
<uib-accordion-group heading="Custom template" template-url="group-template.html">
Hello
</uib-accordion-group>
<uib-accordion-group heading="Delete account" panel-class="panel-danger">
<p>Please, to delete your account, click the button below</p>
<button class="btn btn-danger">Delete</button>
</uib-accordion-group>
<uib-accordion-group is-open="status.open">
<uib-accordion-heading>
I can have markup, too! <i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': status.open, 'glyphicon-chevron-right': !status.open}"></i>
</uib-accordion-heading>
This is just some content to illustrate fancy headings.
</uib-accordion-group>
</uib-accordion>
</div>
angular.module('ui.bootstrap.demo').controller('AccordionDemoCtrl', function ($scope) {
$scope.oneAtATime = true;
$scope.groups = [
{
title: 'Dynamic Group Header - 1',
content: 'Dynamic Group Body - 1'
},
{
title: 'Dynamic Group Header - 2',
content: 'Dynamic Group Body - 2'
}
];
$scope.items = ['Item 1', 'Item 2', 'Item 3'];
$scope.addItem = function() {
var newItemNo = $scope.items.length + 1;
$scope.items.push('Item ' + newItemNo);
};
$scope.status = {
isFirstOpen: true,
isFirstDisabled: false
};
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="//apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular-ui-bootstrap/1.1.2/ui-bootstrap-tpls.js"></script>
<style>
<span style="white-space:pre"> </span>.active{background:red}
</style>
</head>
<body>
<div ng-app="myApp" ng-controller="AccordionDemoCtrl" >
<span style="white-space:pre"> </span> <uib-accordion >
<uib-accordion-group heading="{{group.title}}" ng-repeat="group in groups">
{{group.content}}
</uib-accordion-group>
<span style="white-space:pre"> </span> <uib-accordion-group heading="elset">
<p>Please, to delete your account, click the button below</p>
</uib-accordion-group>
</uib-accordion>
</div>
<script>
var app = angular.module('myApp', ['ui.bootstrap']);
app.controller('AccordionDemoCtrl', function ($scope) {
$scope.groups = [
{
title: 'Dynamic Group Header - 1',
content: 'Dynamic Group Body - 1'
},
{
title: 'Dynamic Group Header - 2',
content: 'Dynamic Group Body - 2'
}
];
});
</script>
</body>
</html>
<uib-accordion close-others="false">
<uib-accordion template-url="setting/setting.html" >
<uib-accordion-group heading="Dynamic Body Content">
<uib-accordion-group heading="elset" is-disabled="true" >
<uib-accordion-group heading="elset" is-open="true" >
<uib-accordion-group heading="elset" panel-class="active">
<uib-accordion-group heading="elset" template-url="tl.html">
<div ng-controller="AlertDemoCtrl">
<script type="text/ng-template" id="alert.html">
<div class="alert" style="background-color:#fa39c3;color:white" role="alert">
<div ng-transclude></div>
</div>
</script>
<uib-alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)">{{alert.msg}}</uib-alert>
<uib-alert template-url="alert.html">A happy alert!</uib-alert>
<button type="button" class='btn btn-default' ng-click="addAlert()">Add Alert</button>
</div>
angular.module('ui.bootstrap.demo').controller('AlertDemoCtrl', function ($scope) {
$scope.alerts = [
{ type: 'danger', msg: 'Oh snap! Change a few things up and try submitting again.' },
{ type: 'success', msg: 'Well done! You successfully read this important alert message.' }
];
$scope.addAlert = function() {
$scope.alerts.push({msg: 'Another alert!'});
};
$scope.closeAlert = function(index) {
$scope.alerts.splice(index, 1);
};
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="//apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular-ui-bootstrap/1.1.2/ui-bootstrap-tpls.js"></script>
<style>
.active{background:red}
</style>
</head>
<body>
<div ng-app="myApp" ng-controller="AlertDemoCtrl" >
<script type="text/ng-template" id="alert.html">
<div class="alert" style="background-color:#fa39c3;color:white" role="alert">
<div ng-transclude></div>
</div>
</script>
<uib-alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)">{{alert.msg}}</uib-alert>
<uib-alert template-url="alert.html">A happy alert!</uib-alert>
<button type="button" class='btn btn-default' ng-click="addAlert()">Add Alert</button>
</div>
<script>
var app = angular.module('myApp', ['ui.bootstrap']);
app.controller('AlertDemoCtrl', function ($scope) {
$scope.alerts = [
{ type: 'danger', msg: 'Oh snap! Change a few things up and try submitting again.' },
{ type: 'success', msg: 'Well done! You successfully read this important alert message.' }
];
$scope.addAlert = function() {
$scope.alerts.push({msg: 'Another alert!'});
}
$scope.closeAlert = function(index) {
$scope.alerts.splice(index, 1);
};
});
</script>
</body>
</html>
uib-alert close="closeAlert($index)">
$scope.closeAlert = function(index) {
$scope.alerts.splice(index, 1);
};
<uib-alert close="closeAlert($index)" dismiss-on-timeout='1000'>
<uib-alert template-url="alert.html">A happy顶顶顶顶 alert!</uib-alert>
<uib-alert type="danger" >
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="//apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular-ui-bootstrap/1.1.2/ui-bootstrap-tpls.js"></script>
<style>
.active{background:red}
</style>
</head>
<body>
<div ng-app="myApp">
<div ng-controller="ButtonsCtrl">
<h4>Single toggle</h4>
<pre>{{singleModel}}</pre>
<button type="button" class="btn btn-primary" ng-model="singleModel" uib-btn-checkbox btn-checkbox-true="1" btn-checkbox-false="0">
Single Toggle
</button>
<h4>Checkbox</h4>
<pre>Model: {{checkModel}}</pre>
<pre>Results: {{checkResults}}</pre>
<div class="btn-group">
<label class="btn btn-primary" ng-model="checkModel.left" uib-btn-checkbox>Left</label>
<label class="btn btn-primary" ng-model="checkModel.middle" uib-btn-checkbox>Middle</label>
<label class="btn btn-primary" ng-model="checkModel.right" uib-btn-checkbox>Right</label>
</div>
<h4>Radio & Uncheckable Radio</h4>
<pre>{{radioModel || 'null'}}</pre>
<div class="btn-group">
<label class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Left'">Left</label>
<label class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Middle'">Middle</label>
<label class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Right'">Right</label>
</div>
<div class="btn-group">
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Left'" uncheckable>Left</label>
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Middle'" uncheckable>Middle</label>
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Right'" uib-uncheckable="uncheckable">Right</label>
</div>
<div>
<button class="btn btn-default" ng-click="uncheckable = !uncheckable">
Toggle uncheckable
</button>
</div>
</div>
</div>
<script>
var app = angular.module('myApp', ['ui.bootstrap']);
app.controller('ButtonsCtrl', function ($scope) {
$scope.singleModel = 1;
$scope.radioModel = 'Middle';
$scope.checkModel = {
left: false,
middle: true,
right: false
};
$scope.checkResults = [];
$scope.$watchCollection('checkModel', function () {
$scope.checkResults = [];
angular.forEach($scope.checkModel, function (value, key) {
if (value) {
$scope.checkResults.push(key);
}
});
});
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="//apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular-ui-bootstrap/1.1.2/ui-bootstrap-tpls.js"></script>
<style>
.active{background:red}
</style>
</head>
<body>
<div ng-app="myApp">
<div ng-controller="ButtonsCtrl">
<pre>Results: {{checkResults}}</pre>
<div class="btn-group">
<label class="btn btn-primary" ng-model="checkModel.left" uib-btn-checkbox>Left</label>
<label class="btn btn-primary" ng-model="checkModel.middle" uib-btn-checkbox>Middle</label>
<label class="btn btn-primary" ng-model="checkModel.right" uib-btn-checkbox>Right</label>
</div>
</div>
</div>
<script>
var app = angular.module('myApp', ['ui.bootstrap']);
app.controller('ButtonsCtrl', function ($scope) {
$scope.checkModel = {
left: false,
middle: true,
right: false
};
$scope.$watchCollection('checkModel', function () {
$scope.checkResults = [];
angular.forEach($scope.checkModel, function (value, key) {
if (value) {
$scope.checkResults.push(key);
}
});
});
});
</script>
</body>
</html>
<label class="btn btn-primary" ng-model="true" uib-btn-checkbox >Left</label>
<button type="button" class="btn btn-primary" ng-model="singleModel" uib-btn-checkbox btn-checkbox-true="1" btn-checkbox-false="0"> Single Toggle</button>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="//apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular-ui-bootstrap/1.1.2/ui-bootstrap-tpls.js"></script>
<style>
.active{background:red}
</style>
</head>
<body>
<div ng-app="myApp">
<pre>{{radioModel || 'null'}}</pre>
<div class="btn-group">
<label class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Left'">Left</label>
<label class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Middle'">Middle</label>
<label class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Right'">Right</label>
</div>
</div>
<script>
var app = angular.module('myApp', ['ui.bootstrap']);
</script>
</body>
</html>
<label class="btn btn-primary" ng-model="radioModel" >Left</label>
<label class="btn btn-primary" ng-model="radioModel">Middle</label>
<label class="btn btn-primary" ng-model="radioModel">Right</label>
<label class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Left'">Left</label>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="//apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular-ui-bootstrap/1.1.2/ui-bootstrap-tpls.js"></script>
<style>
<span style="white-space:pre"> </span>.active{background:red}
</style>
</head>
<body>
<div ng-app="myApp" >
<div ng-controller="CollapseDemoCtrl">
<span style="white-space:pre"> </span><button type="button" class="btn btn-default" ng-click="isCollapsed = !isCollapsed">Toggle collapse</button>
<span style="white-space:pre"> </span><hr>
<span style="white-space:pre"> </span><div uib-collapse="isCollapsed">
<span style="white-space:pre"> </span><div class="well well-lg">Some content</div>
<span style="white-space:pre"> </span></div>
</div>
</div>
<script>
var app = angular.module('myApp', ['ui.bootstrap']);
<span style="white-space:pre"> </span>app.controller('CollapseDemoCtrl', function ($scope) {
$scope.isCollapsed = false;
});
</script>
</body>
</html>
<div uib-collapse="false">
$uibModal
使用方法:
直接注入到控制器中
.controller('name', function($scope,$uibModal) {
<span style="white-space:pre"> </span>$scope.withSelected = function(tem, con) {// 打开modal
<span style="white-space:pre"> </span>var selectNum = 0, selectAction = "";
<span style="white-space:pre"> </span>$scope.isok = false;
<span style="white-space:pre"> </span>$scope.iscancal = false;
<span style="white-space:pre"> </span>$scope.is_no_user = false;
<span style="white-space:pre"> </span>$scope.is_has_user = false;
<span style="white-space:pre"> </span>$scope.selectNum = 0;
<span style="white-space:pre"> </span>$('.user_check:checked').each(function() {
<span style="white-space:pre"> </span>selectNum = selectNum + 1;
<span style="white-space:pre"> </span>});
<span style="white-space:pre"> </span>if (selectNum == 0) {
<span style="white-space:pre"> </span>$scope.isok = true;
<span style="white-space:pre"> </span>$scope.is_no_user = true;
<span style="white-space:pre"> </span>} else {
<span style="white-space:pre"> </span>$scope.selectNum = selectNum;
<span style="white-space:pre"> </span>$scope.isok = true;
<span style="white-space:pre"> </span>$scope.iscancal = true;
<span style="white-space:pre"> </span>$scope.is_has_user = true;
<span style="white-space:pre"> </span>$scope.selectAction = selectAction;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>$scope.enable=function(){
<span style="white-space:pre"> </span>alert(222)//方法
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>$scope.items = {//属性
<span style="white-space:pre"> </span>isok : $scope.isok,
<span style="white-space:pre"> </span>is_no_user : $scope.is_no_user,
<span style="white-space:pre"> </span>iscancal : $scope.iscancal,
<span style="white-space:pre"> </span>is_has_user : $scope.is_has_user,
<span style="white-space:pre"> </span>selectNum : $scope.selectNum,
<span style="white-space:pre"> </span>selectAction : $scope.fselectedtValue,
<span style="white-space:pre"> </span>fun:$scope.enable
<span style="white-space:pre"> </span>};
<span style="white-space:pre"> </span>var _this = this;
<span style="white-space:pre"> </span>var modalInstance = $uibModal.open({
<span style="white-space:pre"> </span>templateUrl : 'setting/modal/' + tem + '.html',
<span style="white-space:pre"> </span>controller : con,
<span style="white-space:pre"> </span>resolve : {//传递信息给model控制器
<span style="white-space:pre"> </span>items : function() {
<span style="white-space:pre"> </span>return $scope.items;
<span style="white-space:pre"> </span>},parent: function(){
<span style="white-space:pre"> </span> return _this
}
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>});
<span style="white-space:pre"> </span>};
被调用者
.controller('ModalWithSelectCtrl', function($scope, $uibModalInstance, items,parent) {
$scope.isok = items.isok;
$scope.is_no_user = items.is_no_user;
$scope.iscancal = items.iscancal;
$scope.is_has_user = items.is_has_user;
$scope.selectNum = items.selectNum;
$scope.selectAction = items.selectAction;
$scope.ok = function() {
$uibModalInstance.close();
parent.enable()//可以调用调用者的方法
};
$scope.cancel = function() {
$uibModalInstance.dismiss();
};
})
1:animation:设置为false,关闭动画效果.默认"true".
2:appendTo:给modal设置一个容器.默认:"body".
3:backdrop:设置false关闭控件背景,默认为"true".
可能的值:
"true":有背景可以通过点击背景来关闭控件.
"false":没有背景.
"static":有背景,但点击背景不能关闭控件.
4:"backdropClass":给背景添加一个样式类.
5:"controller":为modal内容添加控制器.
6:"keyboard":设置modal是否可以通过按键"ESC"关闭,默认:"true".
7:"openedClass":modal打开时,为html body 添加样式类.
8:"size":设置modal的大小.可能的值:
"lg"
"sm"
9:"template":设置modal内容.
10:"templateUrl":通过引入html来设置modal的内容.
11:"windowClass":为modal添加样式类.
12:"windowTopClass":为当前modal添加样式类.
13:"resolve":调用控制器与modal控制器中传递值.
1:"$uibModalInstance.dismiss();":取消modal
2:" $uibModalInstance.close();":关闭modal