Collapse折叠控件使用uib-collapse指令

 <!DOCTYPE html>
<html ng-app="ui.bootstrap.demo" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/Content/bootstrap.css" rel="stylesheet" />
<title></title> <script src="/Scripts/angular.js"></script>
<script src="/Scripts/ui-bootstrap-tpls-1.3.2.js"></script>
<script> angular.module('ui.bootstrap.demo',['ui.bootstrap']).controller('CollapseDemoCtrl', function ($scope) {
$scope.isCollapsed = true; $scope.coled = function () {
console.log("collapsed");
}
$scope.coling = function () {
console.log("collapsing");
}
$scope.exped = function () {
console.log("expanded");
}
$scope.exping = function () {
console.log("expanding");
}
}); </script> </head>
<body>
<div ng-controller="CollapseDemoCtrl">
<button type="button" class="btn btn-default" ng-click="isCollapsed = !isCollapsed">Toggle collapse</button>
<div uib-collapse="isCollapsed" collapsed="coled()" collapsing="coling()" expanded="exped()" expanding="exping()">
<div class="well well-lg">Some content</div>
</div>
</div>
</body>
</html>

折叠控件可以使用的属性有:

(1)         uib-collapse. 默认为false.表示是否收起控件

(2)         collapsed.组件收起之后调用的函数.

(3)         collapsing.组件收起前调用的函数.如果返回一个拒绝的promise,收起动作将被取消

(4)         expanded.组件展开之后调用的函数.

(5)         expanding.组件展开前调用的函数.如果返回一个拒绝的promise,展开动作将被取消

在AngularJS中使用Promise,要使用AngularJS的内置服务$q。下面这个例子返回了一个拒绝的promise:

     <script>
angular.module('ui.bootstrap.demo', ['ui.bootstrap']).controller('CollapseDemoCtrl', function ($scope, $q) {
$scope.isCollapsed = false; $scope.coled = function () {
console.log("collapsed");
}
$scope.coling = function () {
console.log("collapsing"); var deferred = $q.defer();
var promise = deferred.promise; promise.then(function (result) {
alert("Success: " + result);
}, function (error) {
alert("Fail: " + error);
}); deferred.reject("Can't Collapse");
return promise;
}
$scope.exped = function () {
console.log("expanded");
}
$scope.exping = function () {
console.log("expanding");
}
});
</script>

折叠控件是手风琴控件所依赖的组件,下一篇随笔分享手风琴控件。


目录:

AngularJs的UI组件ui-Bootstrap分享(一)

AngularJs的UI组件ui-Bootstrap分享(二)——Collapse

AngularJs的UI组件ui-Bootstrap分享(三)——Accordion

AngularJs的UI组件ui-Bootstrap分享(四)——Datepicker Popup

AngularJs的UI组件ui-Bootstrap分享(五)——Pager和Pagination

AngularJs的UI组件ui-Bootstrap分享(六)——Tabs

AngularJs的UI组件ui-Bootstrap分享(七)——Buttons和Dropdown

AngularJs的UI组件ui-Bootstrap分享(八)——Tooltip和Popover

AngularJs的UI组件ui-Bootstrap分享(九)——Alert

AngularJs的UI组件ui-Bootstrap分享(十)——Model

AngularJs的UI组件ui-Bootstrap分享(十一)——Typeahead

AngularJs的UI组件ui-Bootstrap分享(十二)——Rating

AngularJs的UI组件ui-Bootstrap分享(十三)——Progressbar

AngularJs的UI组件ui-Bootstrap分享(十四)——Carousel


AngularJs的UI组件ui-Bootstrap分享(二)——Collapse的更多相关文章

  1. Android常见UI组件之ListView(二)——定制ListView

    Android常见UI组件之ListView(二)--定制ListView 这一篇接上篇.展示ListView中选择多个项及实现筛选功能~ 1.在位于res/values目录下的strings.xml ...

  2. Android用户界面 UI组件--TextView及其子类(二) Button,selector选择器,sharp属性

    1.XML文件中的OnClick 属性可以指定在Activity中处理点击事件的方法,Activity中必须定义该属性指定的值作为方法的名字且有一个View类型的参数,表示此物件被点击. 2.使用se ...

  3. Android用户界面 UI组件--AdapterView及其子类(二) AdapterViewAnimator及其子类

    AdapterViewAnimator:当在视图间切换时会显示动画. android:animateFirstView 定义ViewAnimation首次显示时是否对当前视图应用动画. android ...

  4. Ionic4.x 中的 UI 组件(UI Components) 侧边栏ion-menu组件以及底部tabs结合 侧边栏 ion-menu

    1.侧边栏 ion-menu 组件的基本使用 1.创建项目 ionic start myApp sidemenu 2.配置项目 属性 作用 可选值 side 配置侧边栏的位置 start end me ...

  5. Ionic4.x 中的 UI 组件(UI Components) 日期组件

    1.日期组件的基本使用 官方文档:https://ionicframework.com/docs/api/datetime 模板中: <ion-datetime display-format=& ...

  6. Ionic4.x 中的 UI 组件(UI Components) Slides 轮播图组件、Searchbar 组件、 Segment 组件

    Slides 轮播图组件 Ionic4.x 中的轮播图组件是基于 swiper 插件,所以配置 slides 的属性需要在 swiper 的 api 中 找 Swiper Api:http://ida ...

  7. Ionic4.x 中的 UI 组件(UI Components)表单相关组件

    1.ion-input 单行文本框 2.ion-toggle 开关 3.ion-radio-group.ion-radio 单选按钮组 4.ion-checkbox 多选按钮组 5.ion-selec ...

  8. 挂号平台首页开发(UI组件部分)

    JQ插件模式开发UI组件 JQ插件开发方法: 1.$.extend() 扩展JQ(比较简单,功能略显不足) $.extend({ sayHello:function(){ console.log(&q ...

  9. AngularJs的UI组件ui-Bootstrap分享(十二)——Rating

    Rating是一个用于打分或排名的控件.看一个最简单的例子: <!DOCTYPE html> <html ng-app="ui.bootstrap.demo" x ...

随机推荐

  1. adpatch options=hotpatch

    --no need to shutdown application and no need to enable maintenance mode adpatch options=hotpatch fi ...

  2. CI 框架访问 http://[::1]/yourproject/

    Chances are you have left the base url blank/* |---------------------------------------------------- ...

  3. 使用Lombok简化你的代码

    一.安装 eclipse 下载:https://projectlombok.org/       双击安装即可. 重启eclipse/myeclipse         如果有报错,clean一下项目 ...

  4. CSS3的chapter3

    CSS的常用样式分为几大类: 字体样式(font,color, text-decoration ,text-shadow) 元素样式(width,height,margin,padding,opaci ...

  5. Unity3d 脚本相互调用

    unity中三种调用其他脚本函数的方法 第一种,被调用脚本函数为static类型,调用时直接用  脚本名.函数名().很不实用…… 第二种,GameObject.Find("脚本所在物体名& ...

  6. BW常用事务码Tcode

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  7. linux SVNUP显示无法连接主机

    今天开发环境中突然无法连接主机了,我就想到 1.更改svn 链接地址,发现不可取,工程中的每个目录下面都有个.svn文件,修改起来麻烦: 2.建立新文件夹,重新checkout,发现还是无法链接 最后 ...

  8. Delphi TDatabase 组件

    TDatabase 组件是一个能与远程数据库通过 BDE 建立连接的组件,可使本地端的程序获取远程的数据. 通过 TDatabase 组件的使用,可以减少与远程数据库连接的窗口,当远程数据库的设置变动 ...

  9. [SoapUI] SoapUI Response 格式控制

    application/后面可以修改为自己所需要的内容格式.

  10. 20160817_Redis配置操作

    ZC: 主要是 做一些配置,使得 java程序能够访问到 redis服务器,主要内容为:ZC: ①.redis服务端服务 重启的命令ZC: ②.取消绑定 本地IP的配置,使得 所有本网段局域网机器都能 ...