1

I want to find the links in text input and turns them into html links in angularjs.Here is my code but its not working. 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'}];

2 Answers 2

1

I think it should be:

<div class="item item-body" ng-bind-html="deal.notification_details | linky"></div>

ngBindHtml expects an expression, hence you don't have to use interpolation markers {{ ... }}.

To open a link in new tab you would use target setting of the linky filter:

ng-bind-html="deal.notification_details | linky:'_blank'"
Sign up to request clarification or add additional context in comments.

7 Comments

Its worked.But its opened in app itself.How can i open the in external browser??
Add target="_blank" attribute to the link: ng-bind-html="deal.notification_details | linky:'_blank'"
Where i will give target="_blank"
See updated answer for how you can add target attribute.
It should work, here is a demo: plnkr.co/edit/heI7ytOS7xWa1ZZiZrWj?p=preview.
|
1

$scope.deal it is json object so get first array item is start from 0

<div class="item item-body" ng-bind-html="deal[0].notification_details | linky"></div> 

DEMO

3 Comments

Based on $scope.deal structure, looks like OP uses ngRepeat like this ng-repeat="deal in deals".
@dfsq where didn't the op uses ng-repeat in the question??
How can i open link in browser ,i tried _blank but its not worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.