87,901
社区成员
发帖
与我相关
我的任务
分享
require.config({
baseUrl:"/",
paths:{
'jquery':'lib/jquery-3.1.1.min',
'angular':'lib/angularjs/angular',
'angular-ui-router':'lib/angular-ui-router/angular-ui-router',
'app':'modules/app',
},
shim:{
'angular':{
deps:['jquery']
},
'angular-ui-router':{
deps:['angular']
},
'app':{
deps:[
'angular-ui-router',
]
},
}
});
require(['app'],function(){
// angular.bootstrap(document,['app']);
});
define(function(){
var app = angular.module('app',['ui.router','core']);
app.constant('menudt', {
"1001":"/customerbinfo",
"1002":"/relcustinfo",
"2001":"/creditapproval",
"9001":"/menumanager"
});
app.config(['$stateProvider','$urlRouterProvider',function($stateProvider,$urlRouterProvider) {
$stateProvider.state({
name:'login',
url:'/login',
templateUrl:'tpls/login.html',
});
$stateProvider.state({
name:'home',
url:'/home',
templateUrl:"tpls/home.html",
});
$stateProvider.state({
name:'index',
url:'/index',
component:'index',
});
$urlRouterProvider.otherwise('/index');
}]);
require(['controllers/references'],function(references){
require(references,function(){
angular.bootstrap(document,['app','core']);
});
});
});
define(function(){
var core = angular.module('core',[]);
core.component('index',{
template:'<h1>....</h1>',
controller:'CoreController',
});
core.service('validate', ['$http', function($http){
this.login = function(successFunc){
$http.get("/server/valilogin?r"+Math.random(),{
cache:false,
}).then(successFunc,function(response){
});
};
}]);
core.service('getdata', ['$http', function($http){
this.getmenudt = function(successFunc){
$http.get("/data/menu.json",{headers:{
'Content-Type':'application/json'
},cache:false}).then(successFunc,function(response){
console.log(response)
});
};
}]);
core.controller('CoreController', ['$scope','$location','validate','getdata',
function($scope,$location,validate,getdata){
validate.login(function(response){
var rs = response.data
if(rs.Result != null){
if (rs.Result == "error" ){
$location.path("/login")
} else {
//$location.path("/home")
}
}
});
}]);
});
define(function(){
return [
'controllers/core',
];
});