jsonData不会在控制台上打印没有错误它只是不会打印

时间:2016-11-23 03:06:54

标签: javascript angularjs json cordova ionic-framework

.controller('StocksCtrl',['$scope','$stateParams','$http',
  function($scope, $stateParams) {

    //http://finance.yahoo.com/webservice/v1/symbols/YHOO/quote?bypass=true&format=json&view=detail
    $http.get("http://finance.yahoo.com/webservice/v1/symbols/YHOO/quote?bypass=true&format=json&view=detail")
      .then(function(jsonData) {
        console.log(jsonData);
      });



  $scope.ticker = $stateParams.stockTicker;
}]);

1 个答案:

答案 0 :(得分:0)

你错过了在函数中注入$http

.controller('StocksCtrl', ['$scope', '$stateParams', '$http',
    function($scope, $stateParams,$http) {

        //http://finance.yahoo.com/webservice/v1/symbols/YHOO/quote?bypass=true&format=json&view=detail
        $http.get("http://finance.yahoo.com/webservice/v1/symbols/YHOO/quote?bypass=true&format=json&view=detail")
            .then(function(jsonData) {
                console.log(jsonData);
            });

        $scope.ticker = $stateParams.stockTicker;
    }
]);