Skip to content

Instantly share code, notes, and snippets.

@srph
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srph/039124ab9a8c67e9a538 to your computer and use it in GitHub Desktop.
Save srph/039124ab9a8c67e9a538 to your computer and use it in GitHub Desktop.
app.config(['$stateProvider', function($stateProvider) {
var auth = {
name: 'auth',
abstract: true,
template: '<div ui-view></div>',
resolve: {
auth: ['AuthSrvc', function(AuthSrvc) {
return AuthSrvc.check()
}]
}
}
var settings = {
name: 'auth.settings'
url: '/settings',
abstract: true,
templateUrl: '/views/auth/settings/template.html',
data: {
pageTitle: 'Settings'
}
};
var profile = {
name: 'auth.settings.profile',
url: '/profile',
templateUrl: '/views/auth/settings/profile/template.html',
controller: 'ProfileSettingsCtrl',
data: {
pageTitle: 'Profile Settings'
},
resolve: {
user: ['UserSrvc', 'AuthSrvc', function(UserSrvc, AuthSrv) {
authID = AuthSrvc.user.id
return UserSrvc.get(authID)
}]
}
};
$stateProvider.state(auth).state(settings).state(profile);
});
@nickeddy
Copy link

app.config(['$stateProvider', function($stateProvider) {
    var states = [];
    states.push({
        name: 'auth',
        abstract: true,
        template: '<div ui-view></div>',
        resolve: {
            auth: ['AuthSrvc', function(AuthSrvc) {
                return AuthSrvc.check()
            }]
        }
    });

    states.push({
        name: 'auth.settings'
        url: '/settings',
        abstract: true,
        templateUrl: '/views/auth/settings/template.html',
        data: {
            pageTitle: 'Settings'
        }
    });

    states.push({
        name: 'auth.settings.profile',
        url: '/profile',
        templateUrl: '/views/auth/settings/profile/template.html',
        controller: 'ProfileSettingsCtrl',
        data: {
            pageTitle: 'Profile Settings'
        },
        resolve: {
            user: ['UserSrvc', 'AuthSrvc', function(UserSrvc, AuthSrv) {
                authID = AuthSrvc.user.id

                return UserSrvc.get(authID)
            }]
        }
    });

    angular.forEach(states, function(state) { $stateProvider.state(state); });
});

@srph
Copy link
Author

srph commented Aug 15, 2014

@nickeddy - doesn't fix the problem, does it? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment