ocLazyLoad angular 按需加载

ionic 框架

1.引用

index.html 加载 <script type="text/javascript" src="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']);
              }]
          }
        })

 

posted @ 2016-08-28 17:55  龙鸿轩  阅读(1027)  评论(0编辑  收藏  举报