app.js
3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
angular.module("ZhaoniuniuApp", ["ionic", "ZhaoniuniuApp.routes", "ZhaoniuniuApp.controllers", "ZhaoniuniuApp.services", "ZhaoniuniuApp.filters"]).run(function($rootScope, $state, $ionicPlatform, $ionicHistory) {
$ionicPlatform.ready(function() {
$ionicHistory.clearHistory();
$ionicHistory.clearCache();
var pageRouter = document.getElementById('pageRouter').value;
var pageRouterParams=document.getElementById('pageRouterParams').value;
if(!!pageRouterParams&&pageRouterParams!=""){
pageRouterParams =eval('(' +pageRouterParams+')');
}else{
pageRouterParams ={};
}
$rootScope.goBack=function(){
if($ionicHistory.backTitle()){
$ionicHistory.goBack();
}else{
window.location.href="http://www.zhao.com/";
}
}
$state.go(pageRouter,pageRouterParams);
});
}).config(function($ionicConfigProvider,$httpProvider) {
$ionicConfigProvider.views.maxCache(5);
$ionicConfigProvider.navBar.alignTitle("center");
//$ionicConfigProvider.backButton.text('返回').icon('ion-chevron-left');
$httpProvider.defaults.headers.put['Content-Type'] = 'application/x-www-form-urlencoded';
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
// Override $http service's default transformRequest
$httpProvider.defaults.transformRequest = [function(data) {
/**
* The workhorse; converts an object to x-www-form-urlencoded serialization.
* @param {Object} obj
* @return {String}
*/
var param = function(obj) {
var query = '';
var name, value, fullSubName, subName, subValue, innerObj, i;
for (name in obj) {
value = obj[name];
if (value instanceof Array) {
for (i = 0; i < value.length; ++i) {
subValue = value[i];
fullSubName = name + '[' + i + ']';
innerObj = {};
innerObj[fullSubName] = subValue;
query += param(innerObj) + '&';
}
} else if (value instanceof Object) {
for (subName in value) {
subValue = value[subName];
fullSubName = name + '[' + subName + ']';
innerObj = {};
innerObj[fullSubName] = subValue;
query += param(innerObj) + '&';
}
} else if (value !== undefined && value !== null) {
query += encodeURIComponent(name) + '='
+ encodeURIComponent(value) + '&';
}
}
return query.length ? query.substr(0, query.length - 1) : query;
};
return angular.isObject(data) && String(data) !== '[object File]'
? param(data)
: data;
}];
});