angular-ui-bootstrap – 不能使用具有Angular UI Bootsrap Aler
我正在使用uib-alert指令,但我想用Bootstrap自己的淡入淡出类或我添加的其他自定义动画来设置警报的关闭动画.我已经看到了其他一些尝试回答这个问题,但没有一个真的令人满意.
以前的答案要么过时(AngularJS/UI Bootstrap – fading out alert on remove),要么在角度添加或删除DOM中的内容时依赖CSS类.ng-enter和.ng-leave(How to add animation to angularjs uib-alert directive) 我更喜欢这样的实现 >更多声明: < uib-alert ng-repeat =“警报中的警报”type =“{{alert.type}}”ng-class =“fade:alert.expired”close =“closeAlert($index)”> {{alert的.msg}}< / UIB警报> < uib-alert ng-repeat =“警报中的警报”type =“{{alert.type}}”ng-class =“alert.expired?alert.closeClass:'fade'”close =“closeAlert($index) “> {{alert.msg}}< / UIB警报> VM329 angular.js:13424错误:[$parse:syntax]语法错误:令牌’,’是意外的,期待[]]在表达式的第75列[alert.expired? alert.closeClass || ‘淡出'[‘alert-‘(打字||’警告’),可以关闭吗? ‘alert-dismissible’:null]]从[,可关闭? ‘alert-dismissible’:null]]. 我在结果标记中也注意到了这一点,但奇怪的是,我没有在源代码中的任何地方看到此字符串连接或三元定义(不在alert模板或alert.js中): ng-class =“[‘alert-‘(type ||’warning’),closeable?’alert-dismissible’:null]” There is also a question尝试使用ngAnimate解决此问题,但ngAnimate seems to have no effect on this directive使用所有包的最新版本: 解决方法
而不是ng-class,请使用type =“{{alert.type}}”.这将解决问题
Plunker
<div uib-alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)" dismiss-on-timeout= 20>{{alert.msg}}</div> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |