I use routeProvider to define controlers and templates for my urls.
When I click on the link, which has the same url as is the actual location, nothing happens. I w
I think it's a simpler approach.
.directive ('a', function ($route, $location) {
var d = {};
d.restrict = 'E';
d.link = function (scope, elem, attrs) {
// has target
if ('target' in attrs) return;
// doesn't have href
if (!('href' in attrs)) return;
// href is not the current path
var href = elem [0].href;
elem.bind ('click', function () {
if (href !== $location.absUrl ()) return;
$route.reload ();
});
};
return d;
});
Assuming You want to make all basic links (without
target
attribute) reload on click and You use relative links in the href
attribute (e.g. /home
instead of http://example.com/home
) You don't have to add any special markup to your HTML (comes handy when updating a site with HTML already written).