如何在angular-ui引导程序警报中包含链接?
尝试:
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>
脚本
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); }; }
在AngularJS表达式中嵌入HTML标记通常不是最好的方法,因为这样您将无法评估AngularJS指令.
原文链接:https://www.f2er.com/angularjs/141849.html无论如何,回到你的问题 – 有很多方法来解决你的问题.如果您刚刚显示链接,最简单的方法是使用ng-bind-html指令(http://docs.angularjs.org/api/ngSanitize.directive:ngBindHtml):
<alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)"> <span ng-bind-html="alert.msg"></span> </alert>