A
A
Alexey Vardugin2016-03-10 10:34:35
Angular
Alexey Vardugin, 2016-03-10 10:34:35

Why doesn't Angularjs ui-sref work until I reload the page or click another link?

There are links, by clicking on them a modal window opens. The first click works fine, but after closing the window, the link is not clickable until the page is reloaded or until I click on the adjacent link.
The link itself:

<a ui-sref="userState({userId: data.id })" data-ui-sref-opts="{reload:false}" data-toggle="modal">View</a>

Route:
.state("userState", {
                parent: "app.new",
                params: {
                    usertId: 0
                },
                onEnter: [
                    "$modal",
                    function($modal) {
                        $modal.open({
                            controller: "UserModalController",
                            templateUrl: 'users/modals/user-modal.html',
                        }).result.finally(function() {
                            $stateProvider.go('^');
                        });
                    }
                ]
            });

Didn't use ng-click because this block is added dynamically (TagInput directive).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2016-03-10
@Aizlee

Because ui-router operates with states. When you click on a link, you enter the app.new.userState state, which you enter with a modal window. But after you have closed the modal window, you remain in the same state, and re-clicking the transition to an already active state does not trigger.
Look into ui-router-extras if you need modals to bind to states.
PS or activate the previous / parent state on closing the modal

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question