ocombe / ocModal

An angularJS modal directive & service
66 stars 16 forks source link

How to link with router? #6

Closed anabelle closed 10 years ago

anabelle commented 10 years ago

Hi,

What would be your recommended approach so that each modal has a unique URL and works together with browser history?

ocombe commented 10 years ago

Hi, you can do this by giving the same id to each route/modal so that they would open in the same modal (and not stack modals one on each other):

$stateProvider.state('login', {
    url: "/login",
    onEnter: ['$ocModal', function($ocModal) {
        $ocModal.open({
            id: "idModal",
            url: "/partials/login.html",
            controller: 'LoginCtrl'
        });
    }]
});

$stateProvider.state('view', {
    url: "/view",
    onEnter: ['$ocModal', function($ocModal) {
        $ocModal.open({
            id: "idModal",
            url: "/partials/view.html",
            controller: 'ViewCtrl'
        });
    }]
});