Reputation: 15
my js file is,
var countryApp = angular.module('countryApp', []);
countryApp.controller('CountryCtrl', function ($scope, $http) {
$http.get('js/countries.json').success(function (data) {
$scope.countries = data;
});
});
its fine when I emulate it on my android phone. but in my chrome browser running under windows 7 does not load the json. help me please......
Upvotes: 0
Views: 386
Reputation: 3994
You should use .then
to resolve your request
. code snippet:
var countryApp = angular.module('countryApp', []);
countryApp.controller('CountryCtrl', function ($scope, $http) {
$scope.countries - {};
var promise = $http.get('js/countries.json');
promise.then(function (data) {
$scope.countries = data;
}), function(reason) {
//on error - use $log is better
console.log('Failed: ' + reason);
};
});
Upvotes: 1