Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same segment, different parameters == no segment update. #30

Closed
airtonix opened this issue Feb 5, 2014 · 3 comments
Closed

Same segment, different parameters == no segment update. #30

airtonix opened this issue Feb 5, 2014 · 3 comments

Comments

@airtonix
Copy link

airtonix commented Feb 5, 2014

Similar to this issue: #15

Except that here is the condition:

Same url pattern thus same segement, but different parameters.

Since this is the logic that determines whether or not to update the segment, we also need to test if the parameters are different.

@airtonix
Copy link
Author

airtonix commented Feb 5, 2014

actually I wrongly assumed this was initiated in the directive, however the directive still makes up part of the problem by not allowing an update on same segmentname, different parameters.

@airtonix
Copy link
Author

airtonix commented Feb 5, 2014

Nvm, Looking at the source code reveals:

https://github.com/artch/angular-route-segment/blob/master/src/route-segment.js#L55

             *                        - `dependencies` is an array of route param names which are forcing the view 
             *                              to recreate when changed;

Which means that :

$routeSegmentProvider
    .segment('page', {
                templateUrl: "page.html",
                dependencies: ['slug', ],
                controller: ["$scope", "$routeParams", function ($scope, $routeParams){
                    $scope.PageUrl = "pages/" + $routeParams.slug + ".html";
                }]
            });

Will cause the segment to update with the routeParam slug changes.

Perhaps the example needs to use this in the example.

@artch
Copy link
Owner

artch commented Feb 5, 2014

You can also use watcher property for this purpose:

.segment('segmentName', {
  ...
  watcher: function(SomeService) {
    return SomeService.someValue(); // if this is changed on $digest-ing, then segment will be reloaded
  }
})

@artch artch closed this as completed Feb 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants