Skip to content

Instantly share code, notes, and snippets.

@heanfig
Created March 27, 2018 02:16
Show Gist options
  • Save heanfig/8580fdd286c488ea20835d5699f1f564 to your computer and use it in GitHub Desktop.
Save heanfig/8580fdd286c488ea20835d5699f1f564 to your computer and use it in GitHub Desktop.
var $routeControllers= "includes/controllers.php";
var $routeControlleri= "includes/controlleri.php";
var $routeControlleru= "includes/controlleru.php";
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider,$httpProvider) {
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
var param = function (obj) {
var query = '', 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;
};
// Override $http service's default transformRequest
$httpProvider.defaults.transformRequest = [function (data) {
return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
}];
$routeProvider
.when("/proyectos", {
templateUrl : 'templates/proyectos.html',
controller : 'proyectosController'
})
});
app.controller('proyectosController', function($http,$scope) {
$scope.rproject = [];
$scope.listProject = [];
//$scope.listProject.push({name:'nombe'});
$http.post($routeControllers,{'accion':1})
.then(function(result){
console.log(result);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment