I just started playing around with ionic and have the following code to call a .net webapi project with identity 2:
$scope.login = function(){
var data = {
grant_type : "password",
username : "myusername",
password : "mypassword"
};
$http.post('http://localhost:59167/token', data, {transformRequest: function (obj) {
alert('posting');
var str = [];
for (var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
}}).success(function (data, status, headers, config) {
alert('success');
$scope.output = data;
}).error(function (data, status, headers, config) {
alert('status: ' + status + " , data: " + data);
$scope.output = data;
});
};
I start the webapi project and set a breakpoint in the GrantResourceOwnerCredentials method. When I run the ionic project using ionic serve, everything works as expected and the breakpoint is hit. However, when I use the android emulator, I get the alert triggered in the error function. I don't know how to debug this, so I can't figure out why it works when I use serve, but not emulate.
Any help would be appreciated.