{"id":17275,"date":"2015-02-13T16:30:22","date_gmt":"2015-02-13T11:00:22","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=17275"},"modified":"2017-11-22T16:00:23","modified_gmt":"2017-11-22T10:30:23","slug":"highlighting-links-in-text-using-linky-filter","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/highlighting-links-in-text-using-linky-filter\/","title":{"rendered":"Highlighting links in text using &#8220;linky&#8221; filter"},"content":{"rendered":"<p>At times\u00a0we come across few\u00a0cases where we need to differentiate the links amongst the plain text. Angular provide us with a very useful filter named : <strong>&#8220;linky&#8221;\u00a0<\/strong>which help us to do so.<\/p>\n<p>With the help of <strong>linky<\/strong> filter we can detect links from text and show them differently . \u00a0Linky takes text and produces HTML\u00a0by wrapping all URLs\u00a0into anchor tags. It supports email address , http, https, and mailto.<\/p>\n<p>For this you would require the <strong>ngSanitize<\/strong> module in angular app.<\/p>\n<p>In HTML\u00a0binding<\/p>\n<p>&lt;p ng-bind-html=&#8221;myText | linky&#8221;&gt; &lt;\/p&gt;<\/p>\n<p>You can also define the target for high-lighted links like this-<\/p>\n<p>&lt;p ng-bind-html=&#8221;myText | linky :&#8217;_blank'&#8221;&gt;<\/p>\n<p>[js]<\/p>\n<p>&lt;!DOCTYPE html&gt;<br \/>\n&lt;html&gt;<br \/>\n&lt;head lang=&quot;en&quot;&gt;<br \/>\n    &lt;meta charset=&quot;UTF-8&quot;&gt;<br \/>\n    &lt;title&gt;Lets try linky filter&lt;\/title&gt;<br \/>\n    &lt;script type=&quot;application\/javascript&quot; src=&quot;angular.js&quot;&gt;&lt;\/script&gt;<br \/>\n    &lt;script src=&quot;LinkyCtrl.js&quot;&gt;&lt;\/script&gt;<br \/>\n    &lt;script src=&quot;http:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/1.2.1\/angular-sanitize.min.js&quot;&gt;&lt;\/script&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;div ng-app=&quot;myApp&quot; ng-controller=&quot;myController&quot;&gt;<br \/>\n    &lt;div&gt;<br \/>\n        &lt;p ng-bind-html=&quot;myText | linky :&#8217;_blank&#8217;&quot;&gt;&lt;\/p&gt;<br \/>\n        &lt;textarea ng-model=&quot;myText&quot; style=&quot;width: 420px; height: 120px&quot;&gt;&lt;\/textarea&gt;<br \/>\n \u00a0 \u00a0&lt;\/div&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;\/body&gt;<\/p>\n<p>&lt;\/html&gt;<\/p>\n<p>[\/js]<\/p>\n<p>In our angular controller,<\/p>\n<p>[js]<\/p>\n<p>var myApp = angular.module(&#8216;myApp&#8217;, [&#8216;ngSanitize&#8217;])<br \/>\n    .controller(&#8216;myController&#8217;, [&#8216;$scope&#8217;, function ($scope) {<br \/>\n        $scope.myText = &quot;Some default text is here http:\/\/www.intelligrape.com\/&quot;;<br \/>\n}]);<\/p>\n<p>[\/js]<\/p>\n<p>So in this way we can quickly highlight the links in angular.<\/p>\n<p>Hope this helps.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At times\u00a0we come across few\u00a0cases where we need to differentiate the links amongst the plain text. Angular provide us with a very useful filter named : &#8220;linky&#8221;\u00a0which help us to do so. With the help of linky filter we can detect links from text and show them differently . \u00a0Linky takes text and produces HTML\u00a0by [&hellip;]<\/p>\n","protected":false},"author":146,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":3},"categories":[1185],"tags":[1186,55,1636,1635],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/17275"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/146"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=17275"}],"version-history":[{"count":1,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/17275\/revisions"}],"predecessor-version":[{"id":52470,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/17275\/revisions\/52470"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=17275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=17275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=17275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}