- var app = angular.module(‘myApp‘, [‘oc.lazyLoad‘, ‘ui.router‘]);
- app.config(function ($stateProvider, $urlRouterProvider) {
- $urlRouterProvider
- .when(‘‘, ‘/‘);
-
- $stateProvider.state(‘index‘, {
- url: ‘/‘,
- templateProvider: function ($stateParams) {
- console.info(‘这是首页‘);
- return ‘<h1>这是首页</h1>‘;
- }
- });
-
- $stateProvider.state(‘main‘, {
- url: ‘/:name‘,
-
-
-
-
-
-
-
- views: {
- "": {
- templateUrl: function ($stateParams) {
- console.info($stateParams);
- return ‘/template/‘ + $stateParams.name + ‘.html‘;
- },
- resolve: {
- des: function ($ocLazyLoad, $stateParams) {
- if ($stateParams.name == ‘about‘)
- return;
- return $ocLazyLoad.load(‘/scripts/myjs/‘ + $stateParams.name + ‘.js‘);
- }
- }
- }
- }
- });
- });
http://blog.csdn.net/u011127019/article/details/53607852