Dropdown values from online JSON


#1

I have been trying to sync dropdown values from JSON which I hosted online. But I couldn’t sync the values.

In controller.js

.controller(‘BusCtrl’, function($scope, $http) {
$http.get(“http://minervaasyncot.com/city.php”).success(function(response){
$scope.cities=response;});
})

In HTML page

{{ x.name }}

What would be the reason ?


#2

did you try $scope.$apply() ?

.controller('BusCtrl', function($scope, $http) {
$http.get("http://minervaasyncot.com/city.php").success(function(response){
$scope.$apply( function(){
$scope.cities = response;
}) ;
});
})

#3

Do you have php header Access-Control-Allow-Origin in your city.php file? Without it, php can’t pass data to outside sources.


#4

Thanks… It worked . I updated php file


#5

You’re welcome! Glad it worked