Skip to content

ui-sref-opts to accept notify option #1875

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

Closed
intellix opened this issue Apr 10, 2015 · 3 comments
Closed

ui-sref-opts to accept notify option #1875

intellix opened this issue Apr 10, 2015 · 3 comments

Comments

@intellix
Copy link

I've got tabs with a fairly large dataset and when you change tab, the old is transitioned back/forward. Anyway, it's quite heavy for me to notify the controller and re-process things. So I removed these categories from the URL and just use ng-click to change category. After using pre-render I see that the other categories aren't linked to/accessible so I'm going to need URLs. I've stumbled upon the notify option on $state.go and this allows the URL to change when I click a link... but there's still no href on my links for prerender to pickup because it happens within an ng-click.

Basically, I want to achieve the following:

<a ui-sref="things({ slug: category.slug })" ui-sref-opts="{notify: false}" ng-click="setCategory(category.slug)">{{category.name}}</a>
angular.module('app').controller('ThingsCtrl', function($scope, $stateParams, ThingService) {

    ThingService.getCategories().then(function(categories) {
        if ($stateParams.slug) {
            ThingService.setCategory($stateParams.slug);
        }
    });

    $scope.setCategory = function(category)
    {
        ThingService.setCategory(slug);
    };
});

This way I get my performance, transitions and prerender picks up hrefs so you can go directly to a category.

Is there any reason why notify isn't whitelisted as an option? On that note, is there a reason why we need to restrict usage of $state.go? As it stands, I have to fork and whitelist it.

@nateabele
Copy link
Contributor

Is there any reason why notify isn't whitelisted as an option? On that note, is there a reason why we need to restrict usage of $state.go? As it stands, I have to fork and whitelist it.

If I recall correctly, things worked a little differently when it was originally introduced, and certain options could have had the potential to cause weird behavior. Now I don't know, we may not need it. Feel free to submit a PR, and be sure to follow the contributor guidelines.

@tamtakoe
Copy link

👍 Merge PR, please

@eddiemonge
Copy link
Contributor

fixed in #2187

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

4 participants