angularjs – Angular UI Bootstrap Alert Closable Issue

前端之家收集整理的这篇文章主要介绍了angularjs – Angular UI Bootstrap Alert Closable Issue前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用 Angular UI Bootstrap生成警报框,使用以下代码

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

它按预期呈现:

我的问题是:是否有某种方法可以将某些通知关闭,而其他通知则根据变量?

我编写了这个模拟代码,并且只在closeable为true时才显示关闭的x.

$scope.alerts = [
    { type: 'danger',closeable: false,msg: 'Oh snap! Change a few things up and try submitting again.' },{ type: 'success',closeable: true,msg: 'Well done! You successfully read this important alert message.' },{ type: 'warning',msg: 'Be careful! Something may go wrong here.' },{ type: 'info',msg: 'Attention! Here is some news for you.' }
];

解决方法

试试你的十字架

<button type="button" class="close" data-dismiss="alert" ng-if="alert.closable">
<span aria-hidden="true">&times;  </span><span class="sr-only">Close</span></button>

猜你在找的Angularjs相关文章