AngularJS Bootstrap警报dismiss-on-timeout属性不起作用

栏目: CSS · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/32023558/angularjs-bootstrap-alert-dismiss-on-timeout-attribute-doesnt-work
我正在尝试使用AngularJS Bootstrap警报,如 here

解释的“dismiss-on-timeout”属性.它在此示例中没有任何效果,警报只是定期出现并且不会消失.

<alert type="warning" dismiss-on-timeout="2000">Alert text</alert>

但它确实在网站的ng-repeat示例中有效:

<alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)" dismiss-on-timeout="2000">{{alert.msg}}</alert>

问题是缺少关闭属性吗?如果是这样,你如何编写一个不属于数组的警报的close函数?

它工作正常,它只是dismissOnTimeout指令调用警报指令控制器的 close method

.该控制器依次使用外部范围关闭方法.所以你需要实现它,以便指令可以调用它:

<alert type="danger" close="closeAlert()" ng-if="show" 
       dismiss-on-timeout="2000">Something happened.</alert>

并在控制器中:

$scope.show = true;

$scope.closeAlert = function(index) {
    $scope.show = false;
};

翻译自:https://stackoverflow.com/questions/32023558/angularjs-bootstrap-alert-dismiss-on-timeout-attribute-doesnt-work


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Web Applications (Hacking Exposed)

Web Applications (Hacking Exposed)

Joel Scambray、Mike Shema / McGraw-Hill Osborne Media / 2002-06-19 / USD 49.99

Get in-depth coverage of Web application platforms and their vulnerabilities, presented the same popular format as the international bestseller, Hacking Exposed. Covering hacking scenarios across diff......一起来看看 《Web Applications (Hacking Exposed)》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换