Skip to content

Instantly share code, notes, and snippets.

@houming818
Last active August 7, 2017 12:03
Show Gist options
  • Save houming818/cdb04027cb76c13c64eb4077be264602 to your computer and use it in GitHub Desktop.
Save houming818/cdb04027cb76c13c64eb4077be264602 to your computer and use it in GitHub Desktop.
angluarjs dynamic states example
angular.module('MetronicApp').controller('LvsGroupsController', function($model, $scope, localStorageService, $rootScope, $http, $timeout, runtimeStates, $state) {
runtimeStates.addState('lvs', {
name: 'lvs',
url: '/lvs',
data: {pageTitle: 'Lvs中心'},
templateUrl: '/static/views/lvs/main.html',
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'MetronicApp',
insertBefore: '#ng_load_plugins_bebore',
files: ['/static/js/lvs/workflow.js']
});
}]
}
});
runtimeStates.addState('lvs.group', {
name: 'lvs.group',
url: '/group',
data: {pageTitle: 'Lvs中心.group'},
templateUrl: '/static/views/lvs/workflow.html',
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'MetronicApp',
insertBefore: '#ng_load_plugins_bebore',
files: ['/static/js/lvs/workflow.js']
});
}]
}
});
$scope.new = function() {
$state.go('lvs.group');
};
}
MetronicApp.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);
}
};
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment