alert指令会在页面上显示一条提示消息,效果是这样:

代码为:

 <!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('AlertDemoCtrl', function ($scope) {
$scope.alerts = [
{ type: 'danger', msg: '出错消息' },
{ type: 'success', msg: '成功消息' },
{ type: 'info', msg: '提示消息' },
{ type: 'warning', msg: '警告信息' }
]; $scope.addAlert = function () {
$scope.alerts.push({ msg: '这是一条消息!' });
}; $scope.closeAlert = function (index) {
$scope.alerts.splice(index, 1);
};
$scope.addTplAlert = function () { }
}); </script>
<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> </head>
<body>
<div ng-controller="AlertDemoCtrl">
<uib-alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)">{{alert.msg}}</uib-alert>
<button type="button" class='btn btn-default' ng-click="addAlert()">Add Alert</button>
<hr />
<uib-alert template-url="alert.html">一个使用自定义模板的警告框!</uib-alert>
</div>
</body>
</html>

alert指令可以使用的属性有:

属性名 默认值 备注
close   提示消息关闭时所触发的函数。如果有这个属性,提示消息的右侧会添加一个关闭按钮
dismiss-on-timeout none 在有close属性的前提下,设置一个自动关闭提示消息的时间(毫秒)
template-url uib/template/alert/alert.html  
type warning 提示消息的类型。可配置的值有:danger,warning,info,success

目录:

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分享(九)——Alert的更多相关文章

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

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

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

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

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

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

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

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

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

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

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

    最近几个月学习了AngularJs和扩展的UI组件,并在公司小组内做了一次分享交流,感觉很有收获,在此记录下个人的学习心得. 目录: AngularJs的UI组件ui-Bootstrap分享(一) A ...

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

    Carousel指令是用于图片轮播的控件,引入ngTouch模块后可以在移动端使用滑动的方式使用轮播控件. <!DOCTYPE html> <html ng-app="ui ...

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

    进度条控件有两种指令,第一种是uib-progressbar指令,表示单一颜色和进度的一个进度条.第二种是uib-bar和uib-progress指令,表示多种颜色和多个进度组合而成的一个进度条. 这 ...

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

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

随机推荐

  1. Jmeter学习(二)

    1. Jmeter预置知识-http协议 应用层协议http,ftp,smtp 1) http之url http 超文本传输协议,基于请求与响应模式的,无状态,应用层协议. http url: htt ...

  2. spring-task

    cronExpression的配置说明,具体使用以及参数请百度google 字段   允许值   允许的特殊字符 秒    0-59    , - * / 分    0-59    , - * / 小 ...

  3. 慕课网__CSS__ Relative, absolute,

    同时又left, right  或者 top, bottom时 relative, 尽量少用,会出现层级覆盖, 或者单独使用, 避免层级嵌套, 或者覆盖 absolute具有包裹性, 和破坏性 包裹性 ...

  4. Web后台开发技术 经验路线图

    一篇文章:http://www.cnblogs.com/Hiker/archive/2012/11/04/houtaijishu.html

  5. 【图像】Matlab图像标定工具箱

    参考教程: Matlab工具箱教程  http://www.vision.caltech.edu/bouguetj/calib_doc/ 摄像机模型  http://oliver.zheng.blog ...

  6. 模板列onclick事件中绑定跳转页参数(onclick location.href Eval)

    <asp:GridView runat="server" ID="gvCheckList" AutoGenerateColumns="false ...

  7. cocoapod集成失败,无法找到头文件的解决办法

    在终端更新pod的时候,提示警告: target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support ...

  8. 简化通过classname查找 方法

    function getClass(oParent,sclass){ var aEle=oParent.getElementsByTagName('*'); var result=[]; for(va ...

  9. 《精通MVC5.0》笔记Razor

    1.1.视图声明数据类型 Razor声明都是@开始,例如@model MVC.Models.Product声明了控制器创给视图的数据类型,这样就可以在视图使用@Modle.property访问数据,如 ...

  10. linux 下 PHP Notice: session_start(): ps_files_cleanup_dir 报错 问题剖析

    如果在ubuntu/Debian下, 采用apt安装的PHP, 那么在使用Session的时候, 就可能会有小概率遇到这个提示. 代码如下: PHP Notice: session_start(): ...