0

I am trying to use href and ng-click in a tag.

<a href="#/home" ng-click="ctl.modify()"> </a>

When I use href and ng-click in a tag, ng-click is working but href is not working.

Please let me know how to make href work?

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
mahi244
  • 97
  • 3
  • 10
  • refer this answer http://stackoverflow.com/questions/17717072/angularjs-ng-click-and-href-on-anchor – Arun AK Sep 14 '15 at 05:38

3 Answers3

0

Use ng-href here with anchor tag. DEMO

  <a ng-href="#/home" ng-click="ctl.modify()"> </a>
SVK
  • 2,107
  • 2
  • 20
  • 41
0

Try this code:

HTML code:

   <a ng-click="go('/home')"></a>

JS code:

$scope.go = function ( path ) {
  $location.path( path );
};
SVK
  • 2,107
  • 2
  • 20
  • 41
  • Thanks, I am in \home page and i want reload the same (\home) page with ng-click, $location.path(path) is not reloading the same page. So , i tried with $route.reload(); it worked :-) . – mahi244 Sep 14 '15 at 16:08
  • ohh okay. that's nice.. :) @mahi244 – SVK Sep 15 '15 at 04:50
0

In your ctl.modify() function you have to add this row:

$location.path('/home');

Don't forget to add $location as a dependency in the controller params.