I am working in ionic-framework I am doing a login page when I give the username and password and click login then I am getting data from the server.
I have pushed my details that I need in a array called var products = [];
and I am trying to set the data to service to access in another controller while log i am getting undefined value I am not sure where I went wrong some help please.
Here is my plunker https://plnkr.co/edit/P6YmiLsl4mOwBEf4GN7V please let me know if some one find any error.
Replace your post request with this
$http.post("http://aflaree.com/qrcodeservice/Service1.svc/login", loginPost)
.success(function(response) {
console.log(response);
$scope.buildingsNameArray = response.buildings
console.log($scope.buildingsNameArray);
$scope.buildingsNameArray.forEach(function(item) {
console.log(item.Buildingname);
products.push(item.Buildingname);
console.log(passData);
})
var passData = MyService.setData(products);
$state.go('details');
console.log(products);
})
.error(function(response) {
console.log(response);
});
};