Created
September 10, 2015 07:03
-
-
Save tuvokki/7e7060aa28da4855f62d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//See: http://stackoverflow.com/questions/15937267/inject-service-in-app-config | |
//See: http://stackoverflow.com/questions/14688290/inject-dependencies-in-run-method-of-the-module-in-angularjs | |
var app = angular.module('SystemSettings', ['ui.router', 'formly', 'formlyBootstrap']); | |
/** | |
* Set up routing | |
*/ | |
app.config(function($stateProvider, $urlRouterProvider) { | |
// For any unmatched url, redirect to /main | |
$urlRouterProvider.otherwise('/main/general'); | |
// Now set up the states | |
$stateProvider | |
.state('main', { | |
url: '/main', | |
templateUrl: '/static/js/modules/main/index.html', | |
controller: 'MainController' | |
}) | |
.state('main.general', { | |
url: '/general', | |
templateUrl: '/static/js/modules/general/index.html' | |
}) | |
.state('state2', { | |
url: '/state2', | |
templateUrl: '/static/js/modules/hello/hello.html' | |
}) | |
.state('state2.list', { | |
url: '/list', | |
templateUrl: 'partials/state2.list.html', | |
controller: function($scope) { | |
$scope.things = ['A', 'Set', 'Of', 'Things']; | |
} | |
}); | |
}); | |
app.value('serviceUrl', '/REST/SystemSettings/demo/demo_webclient/SystemSettingsService'); | |
app.provider('runtimeStates', function runtimeStates($stateProvider) { | |
// Runtime dependencies for the service can be injected here, at the provider.$get() function. | |
this.$get = function($q, $timeout, $state) { // For example | |
return { | |
addState: function(name, state) { | |
$stateProvider.state(name, state); | |
} | |
}; | |
}; | |
}); | |
app.run(['runtimeStates', function(runtimeStates) { | |
console.log('app run'); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment