scottcorgan/angular-linkify

Fix some other errors

fidoboy opened this issue · 5 comments

In linkify function you must add this:

if (!_str) return "";

before the _str.replace to avoid unexpected errors.

Also, i'm trying to modify the function to add hg-click attribute instead of using the href but i can't understand why it's removed by angular. The function returns the element right, with the ng-click attribute but then it's not rendered on the page. I'm using ng-bind-html="item.text | linkify"

Can you elaborate on hg-click is that a custom directive?

it's ng-click sorry, auto corrector makes that mistakes sometimes… 😄

Can you show me more of the code you're having issues with?

sample code:

<div ng-bind-html="item.htmltext | linkify"></div>

then in likify function i've modified:

anch.href = url;
anch.target = "_blank";
anch.innerHTML = url;
wrap.appendChild(anch);
return wrap.innerHTML;

into this:

anch.href = "javascript:void(0)";
anch.setAttribute("ng-click","openURL('"+url"')");
anch.target = "_blank";
anch.innerHTML = url;
wrap.appendChild(anch);
return wrap.innerHTML;

the function return the ng-click attribute, but then it disappears when the page is rendered.

Still am unable to figure this out. I will continue to investigate.

On Thu, Mar 27, 2014 at 3:57 PM, fidoboy notifications@github.com wrote:

sample code:

then in likify function i've modified:

´´´
anch.href = url;
anch.target = "_blank";
anch.innerHTML = url;
wrap.appendChild(anch);
return wrap.innerHTML;

into this:

anch.href = "javascript:void(0)";
anch.setAttribute("ng-click","openURL('"+url"')");
anch.target = "_blank";
anch.innerHTML = url;
wrap.appendChild(anch);
return wrap.innerHTML;

the function return the ng-click attribute, but then it disappears when the page is rendered.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-38871420
.

  • Scott