Skip to content

Instantly share code, notes, and snippets.

@tuvokki
Created September 10, 2015 07:03
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 tuvokki/7e7060aa28da4855f62d to your computer and use it in GitHub Desktop.
Save tuvokki/7e7060aa28da4855f62d to your computer and use it in GitHub Desktop.
//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