$resource GET google Finance

by jaimem

HTML

<!doctype html>
<html ng-app="app">
    <head>

        <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular-resource.min.js">
        </script>
    </head>
<body>
    
    <div ng-controller="AppCtrl">{{indexResult[0]}}</div>
    
</body>
</html>

JavaScript

angular.module('app', ['ngResource']);

function AppCtrl($scope, $resource) {
    
    $scope.googleFinance = $resource('https://finance.google.com/finance/info', 
                                     {client:'ig', callback:'JSON_CALLBACK'},
                                     {get: {method:'JSONP', params:{q:'INDEXSP:.INX'}, isArray: true}});

    $scope.indexResult = $scope.googleFinance.get();

}