Dropdown values from online JSON

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 ?

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;
}) ;
});
})

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

1 Like

Thanks… It worked . I updated php file

You’re welcome! Glad it worked