包括角UI引导警报链接?

编程入门 行业动态 更新时间:2024-10-19 08:54:00
本文介绍了包括角UI引导警报链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我如何包括角的UI引导警报链接?

尝试:

Plunker例

HTML

< D​​IV NG控制器=AlertDemoCtrl>    <警报NG重复=警戒警报中TYPE =alert.type亲密=closeAlert($指数)> {{alert.msg}}< /警报>    <按钮类='BTN'NG点击=addAlert()>添加警报< /按钮>< / DIV>

脚本

函数AlertDemoCtrl($范围){  $ scope.alerts = [    {类​​型:'错误',味精:'噢单元!改变一些事情,并尝试重新提交。 },    {类​​型:'成功',味精:'< A HREF =>干得好< / A>!你成功读取这个重要的警报消息。 }  ];  $ scope.addAlert =功能(){    $ scope.alerts.push({味精:另一个警报!});  };  $ scope.closeAlert =功能(指数){    $ scope.alerts.splice(指数,1);  };}

解决方案

在AngularJS前pression嵌入HTML标记通常不是因为这样你将不能够评估AngularJS指令的最佳途径。

不管怎样,回到你的问题 - 大约有你的问题得到的许多方面。如果你只是显示链接最简单的方法去将是使用 NG-绑定-HTML 指令之后(docs.angularjs/api/ngSanitize.directive:ngBindHtml):

<警报NG重复=警戒警报中TYPE =alert.type亲密=closeAlert($指数)>    <跨度NG绑定-HTML =alert.msg>< / SPAN>  < /警报>

工作普拉克:plnkr.co/edit/Ftab0xtcelXcHSZbFRxs?p=$p$pview

How do I include links in an angular-ui bootstrap alert?

Attempt:

Plunker Example

HTML

<div ng-controller="AlertDemoCtrl"> <alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)">{{alert.msg}}</alert> <button class='btn' ng-click="addAlert()">Add Alert</button> </div>

Script

function AlertDemoCtrl($scope) { $scope.alerts = [ { type: 'error', msg: 'Oh snap! Change a few things up and try submitting again.' }, { type: 'success', msg: '<a href="">Well done!</a> You successfully read this important alert message.' } ]; $scope.addAlert = function() { $scope.alerts.push({msg: "Another alert!"}); }; $scope.closeAlert = function(index) { $scope.alerts.splice(index, 1); }; }

解决方案

Embedding HTML markup in AngularJS expression is usually not the best approach as this way you won't be able to evaluate AngularJS directives.

Anyway, coming back to your question - there are many ways of getting around your problem. If you are just after displaying links the simplest way to go would be to use the ng-bind-html directive (docs.angularjs/api/ngSanitize.directive:ngBindHtml):

<alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)"> <span ng-bind-html="alert.msg"></span> </alert>

Working plunk: plnkr.co/edit/Ftab0xtcelXcHSZbFRxs?p=preview

更多推荐

包括角UI引导警报链接?

本文发布于:2023-11-26 18:10:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634635.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   链接   UI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!