首页 > 代码库 > ocLazyLoad angular 按需加载

ocLazyLoad angular 按需加载

ionic 框架

1.引用

index.html 加载 <script type="text/javascript" src="http://www.mamicode.com/lib/oclazyload/ocLazyLoad.min.js"></script>

2.注入

angular.module(‘starter‘, [‘ionic‘, ‘oc.lazyLoad‘])

3.配置

.state(‘app.myinfo‘, {            url: ‘/user/myinfo‘,            views: {                ‘menuContent‘: {                    templateUrl: ‘templates/user/myinfo.html‘,                    controller: ‘myinfoCtrl‘                }            }          , resolve: { // Any property in resolve should return a promise and is executed before the view is loaded              loadMyCtrl: [‘$ocLazyLoad‘, function ($ocLazyLoad) {                  // you can lazy load files for an existing module                  return $ocLazyLoad.load([‘js/controllersuser.js‘, ‘js/directive.js‘]);              }]          }        })

 

ocLazyLoad angular 按需加载