0
我使用HTML換行過濾器<br>
更換\n
這樣過濾NG綁定,HTML,如果打開新的標籤頁
angular
.module('App')
.filter('addHtmlLineBreaks', addHtmlLineBreaks);
function addHtmlLineBreaks() {
return function (text) {
var output = text.replace(/\n/g, '<br/>');
return output;
};
}
給出一個錯誤,那麼我就用ng-bind-html
<p ng-bind-html="coach.Description | addHtmlLineBreaks"></p>
申請
一切似乎都做工精細,但我有一個鏈接的地方,打開新的標籤頁
<a ui-sref="Detail" target="_blank">
現在仍然過濾工作,但它給出一個錯誤
angular.js:13920 TypeError: Cannot read property 'replace' of undefined
at mtc.min.js:1
at fn (eval at compile (angular.js:14817), <anonymous>:4:311)
at regularInterceptedExpression (angular.js:16043)
at expressionInputWatch (angular.js:15948)
at Scope.$digest (angular.js:17515)
at Scope.$apply (angular.js:17790)
at done (angular.js:11831)
at completeRequest (angular.js:12033)
at XMLHttpRequest.requestLoaded (angular.js:11966)
任何想法發生了什麼以及如何修復?