0

I want to change location on clicking the div .

Below is code

    <div class="divsub" ng-repeat="item1 in content" ng-click="go('/{{item1.title }}')">
    <div class="divsubtitle"><a >{{item1.title}}</a></div>
    <div class="divsubinner"></div>
    <div class="divsublink">
         <div style="float:left;text-decoration:underline;margin-left:19px">View Demo</div>
         <div style="float:left;text-decoration:underline;margin-left:10px">Download</div>
    </div>
</div>

Below is my controller

first2.controller('nameListCtrl', function ($scope,urls_list) 
{
    $scope.content=urls_list;
    $scope.go=function(path)
    {
        alert(path)
    }
}); 

Why alert is not working on clicking the div

bharath
  • 845
  • 2
  • 11
  • 23

3 Answers3

2

No need to use interpolation {{ }} because its already an angular expression inside an angular directive ng-click

Just use

ng-click="go(item1.title)"

Also see when to use single, double and no curly braces in angular directives: https://stackoverflow.com/a/17879046/1177295

Community
  • 1
  • 1
Raghavendra
  • 5,281
  • 4
  • 36
  • 51
1

SImply change

ng-click="go('item1.title)"

to

ng-click="go(item1.title)"

Here is a DEMO

iJade
  • 23,144
  • 56
  • 154
  • 243
  • i tried that too still not working... it works when i pass something like this ng-click="go('aaaaaa')" instead of ng-click="go('/{{item1.title }}')" – bharath Jul 11 '14 at 11:12
0

So your HTML can be changed as like below

<div class="divsub" ng-repeat="item1 in content" ng-click="ng-click="go(item1.title)"">
<div class="divsubtitle"><a >{{item1.title}}</a></div>
<div class="divsubinner"></div>
<div class="divsublink">
     <div style="float:left;text-decoration:underline;margin-left:19px">View Demo</div>
     <div style="float:left;text-decoration:underline;margin-left:10px">Download</div>
</div>

From the above comments and answer

Anto king
  • 1,222
  • 1
  • 13
  • 26