splash27 splash27 - 1 year ago 60
AngularJS Question

How to route to same location to restart view and controller binding (angularjs)?

Actually, I want something like this

but angular by default doesn't allow this. Is there a way to override it?

I need this to renew view and controller binding?


So, I have in my model statements like this:

$scope.instance =
City: gettextCatalog.getString(cityName),
Country: gettextCatalog.getString(countryName),

So, if I change a language, the
will not be recalculated. I think, that rebinding on reroute is more easy way than inserting every 'instance' in function, that will be called after language changed.

Answer Source

If you are using ngRoute


$route is used for deep-linking URLs to controllers and views (HTML partials). It watches $location.url() and tries to map the path to an existing route definition.

reload(); Causes $route service to reload the current route even if $location hasn't changed. As a result of that, ngView creates new scope and reinstantiates the controller.

If you are using ui.router

$state.go($state.$current, null, { reload: true });