AngularJS variable value in location.href in onclick is not resolved

In HTML, I have an angular variable called

boards.current.url

whose meaning i can be seen through

{{boards.current.url}}

However, I want to use this value in location.href as shown below,

<div class="board" onclick="location.href='{{boards.current.url}}'" style="cursor: pointer;">

      

it doesn't work - angular variable value

boards.current.url

not allowed - any ideas?

+3


source to share


2 answers


use angular-directive instead ng-click

onclick



<div class="board" ng-click="location.href='{{boards.current.url}}'" style="cursor: pointer;">

      

+1


source


The correct way to write this is to use ng-href:

<div class="board" ng-href="{{boards.current.url}}" style="cursor: pointer;">

      



https://docs.angularjs.org/api/ng/directive/ngHref

+1


source







All Articles