In an Angular app, I have a list of hyperlinks that should have the following behavior:
if a certain condition is present (for example, if a certain cookie has the value x), clicking on the hyperlink should open a modal window;
if this condition is not met (for example, if the cookie is set to y), the hyperlink should act in the usual way and open the link in a new tab.
Hyperlinks are formatted as follows:
<a ng-href="{{article.url}}" target="_blank" ng-click="myFunction()"> {{article.title}} </a>
I am puzzled by how to implement this behavior. If I leave both the ng-href and ngclick , then ng-href will insert the url and each click will open the page in a new tab. If I remove the ng-href directive, then the only way to open the link in another tab is through javascript, but this will prevent most browsers. I couldnβt come up with a way to make ng-href conditional (for example, the record <a ng-href="myCondition === true ? {{article.url}} : '#'"> does not work).
Could you suggest a way to implement such functionality in Angular?
angularjs hyperlink angularjs-ng-click
azangru
source share