app.controller('treeController',['$http','$scope','dataService',function($http,$scope,dataService){
var treedata_avm=$http.get('WS/tree').success(function(data){
});
console.log(treedata_avm);
$scope.my_data = treedata_avm;
}]);How do i get only the data instead of other attributes as shown?
发布于 2016-02-19 20:21:29
您可以尝试如下所示:
app.controller('treeController',['$http','$scope','dataService',function($http,$scope,dataService){
var treedata_avm;
$http.get('WS/tree').success(function(response){
treedata_avm = response.data;
console.log(treedata_avm);
$scope.my_data = treedata_avm;
});
}]);发布于 2016-02-19 20:21:52
您没有考虑到Javascript中的异步编程。Google上有很多很好的资源,但是这个例子应该是这样的:
app.controller('treeController', ['$http', '$scope', 'dataService', function($http, $scope, dataService) {
$http.get('WS/tree').success(function(data) {
$scope.my_data = data;
});
}]);https://stackoverflow.com/questions/35505151
复制相似问题