因为记性不好的原因做个草稿笔记
app.js中
var myApp = angular.module('myApp',['ui.router','oc.lazyLoad','ngAnimate','数据处理','公共js方法']);
注册权限访问服务
myApp.factory('$permissions',['$rootScope','$es',function($rootScope,$es){
//...
}]);
myApp.run(['$rootScope','$state','$stateParams','$permissions','$es','缓存公共函数$istore','$modal','$timeout',
function($rootScope,$state,$stateParams,$permissions,$es,$istore,$modal,$timeout){
//...处理配置信息到模块
//进行微信浏览器判断
var isMicroMessenger r= function(){
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
return true;
} else {
return false;
}
}
$rootScope.iswx = isMicroMessenger ();
//切换主题
var skinString == 'skinBlueskinRedskinGreenskinOrange";
var skinPath = config.basic.theme || "skinBlue"
if(skinString.indexOf(skinPath) == -1) skinPath = 'skinBlue';
angular.element('#cssfile').attr('href','style/'+skinPath+'.css')
}]).config(['$stateProvider','$urlRouterProvider',function($stateProvider,$urlRouterProvider){
//版本控制
function getVersion(){
var date = new Date();
var v = date.getTime();
return "?v="+v;
}
var version = getVersion();
//路由
$urlRouterProvider.otherwise('/app');
$stateProvider.state('app',{
url:'/app',
templateUrl:'view/public/app.html'+version,
resolve:{
service:'UserInfoService',
ctrl:['$ocLazyLoad',function($ocLayload){
return $ocLazyLoad({
files:[
'scripts/home-ctrl.js'+version
]
})
}
}
})
//产品模块举例
.state('products',{
url:'/products',
template:'<div ng-class="transition"></div>',
//abstract 抽象模板抽象模板不能被激活,但是它的子模板可以被激活
abstract:true,
resolve:{
service1:'ProductService',
service2:['$ocLazyLoad',function($ocLayload){
return $ocLazyLoad({
files:[
'scripts/product-ctrl.js'+version,
'view/css/product.css'+version
]
})
}
}
})
.state('products.productList',{
url:'/productList',
templateUrl:'view/product/productList.html'+version,
title:'产品列表',
controller:'ProductCtrl'
}
})
}])
}]);