2

I have a page that uses several directives:

<section class="start_page page--no-vcenter">
        <u-search>
            <u-search-form></u-search-form>
            <u-news-form></u-news-form>
            <u-search-pane></u-search-pane>
        </u-search>
        <u-news>
            <u-news-pane></u-news-pane>
        </u-news>
    </u-search>
</section>

When i use a service that uses $location and sets the search() parameters inside of one of the directives all directives repaint.

return $location.search(obj);

How can avoid this repainting of the other directives?

Im using Angular 1.2.28.

ivoba
  • 5,780
  • 5
  • 48
  • 55
  • What do you want to achieve here? – Ankit Agarwal Aug 18 '17 at 12:56
  • I want to set the parameters in the url when some filter gets changed inside of the search-form directive: url?foo=baz – ivoba Aug 18 '17 at 12:58
  • but without repainting the news directive which would cause api calls – ivoba Aug 18 '17 at 13:00
  • so you change `$location.search()` params in `` for example but `` and `` also refresh? Do you use `$location` in these sub-directives too? – con Aug 18 '17 at 13:28
  • yes i use $location in ``. i notice that the whole section gets reloaded. – ivoba Aug 18 '17 at 13:33
  • you can try to assign the `$location` service to a `$scope.location` in `` and use only the inherited `location` in all sub-directives (in case you dont use them anywhere else) - so maybe the refresh/event doesn't bubble up globally (so only the actual scope is in the refresh cycle) – con Aug 18 '17 at 13:51

1 Answers1

0

The solution was quite simple since i was only updating the search() part, resp. the query params.

Here you can use

$routeProvider.when('/somewhere', {
    controller: 'SomeCtrl',
    reloadOnSearch: false
})

When changing the path it would be more complicated, i guess.

The issue on github is this: https://github.com/angular/angular.js/issues/1699

And the solution i found in this answer: https://stackoverflow.com/a/17606908/541949

ivoba
  • 5,780
  • 5
  • 48
  • 55