Justin Cross
Justin Cross

Reputation: 99

Link to current page does nothing in AngularJS

if I am on the /contact page on my website, if my nav bar has a link to the /contact and I click it, nothing happens. But if I click any other link that isn't the current url, Angular responds correctly. How do I make it reload the current page when clicking a link to itself in AngularJS?

Upvotes: 1

Views: 61

Answers (2)

Andriy Ivaneyko
Andriy Ivaneyko

Reputation: 22041

Create function which reloads controller and attach that function to view

$scope.reloadController = function ({
      $state.go($state.current, {}, { reload: true });
})

And atach it to link:

<a ng-click="reload()">Contacts</button>

Upvotes: 1

David Brossard
David Brossard

Reputation: 13834

If the link is to the current page it's actually smart that it doesn't reload. Try using a JavaScript function e.g. reload

http://www.w3schools.com/jsref/met_loc_reload.asp

Upvotes: 0

Related Questions