[英]AngularJs: Find links with initial 'www' in the text and turns them into html links
[英]Finds links in text input and turns them into html links in angularjs
我想在文本輸入中找到鏈接並將它們轉換為angularjs中的html鏈接。這是我的代碼,但無法正常工作。 HTML
<div class="item item-body" ng-bind-html="{{deal.notification_details}} | linky" >
</div>
controller.js
$scope.deal=[{id:'0',notification_details:'sample description http://www/example.com'}];
我認為應該是:
<div class="item item-body" ng-bind-html="deal.notification_details | linky"></div>
ngBindHtml
需要一個表達式,因此您不必使用插值標記{{ ... }}
。
要在新標簽頁中打開鏈接,您可以使用鏈接過濾器的目標設置:
ng-bind-html="deal.notification_details | linky:'_blank'"
$ scope.deal它是json objec t,因此獲取第一個數組項是從0開始
<div class="item item-body" ng-bind-html="deal[0].notification_details | linky"></div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.