Last active
August 7, 2017 12:03
-
-
Save houming818/cdb04027cb76c13c64eb4077be264602 to your computer and use it in GitHub Desktop.
angluarjs dynamic states example
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
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'); | |
}; | |
} |
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
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