After trying what this question ask, I'm asking again how to retrieve data from web using AngularJS in the Ionic framework. Basically, I do what the answer says:
.factory('Advices', function($http) {
var advices = null;
$http.get('http://myurl.myext/myfile.json').success(function (data) {
advices = data;
}).error(function(error) {
console.log('error'); //even if there i print the error it prints nothing
});
//etcetera
How can I rescue that file from my server?
Please try to following code
var app = angular.module('myApp', ['ionic']);
app.controller('mainInfoFactory', ['$scope', '$http', function($scope,$http) {
$http.get("http://myurl.myext/myfile.json")
.success(function (response)
{
$scope.advices = response;
})
.error(function(data) {
alert("ERROR");
});
}]);
Here myAPP and mainInfoFactory are AngularJS application name and controller respectively.
For example : ng-app="myApp" ng-controller="mainInfoFactory"