I am currently following a tutorial in AngularJS. This is the code in the controller.js file.
'use strict'; angular.module ( 'F1FeederApp.controllers' , [] ) .controller ( 'driversController' , function ( $scope , ergastAPIservice ) { $scope.nameFilter = null; $scope.driversList = []; ergastAPIservice.getDrivers ().success ( function ( response ) { $scope.driversList = response.MRData.StandingsTable.StandingsLists [ 0 ].DriverStandings; }); });
I get the following errors:
1) A blocked download resource from url is not allowed by the $ sceDelegate policy.
2) TypeError: ergastAPIservice.getDrivers (...). Success is not a function
I'm not quite sure what might cause these errors, but I'm very new to Angular. The only possible differences that I saw between my and other examples are that in this block of code: (services.js)
'use strict'; angular.module ( 'F1FeederApp.services' , [] ) .factory ( 'ergastAPIservice' , function ( $http ) { var ergastAPI = {}; ergastAPI.getDrivers = function () { return $http ({ method : 'JSONP' , url : 'http://ergast.com/api/f1/2013/driverStandings.json?callback=JSON_CALLBACK' }); }; return ergastAPI; });
The differences I noticed are that I have a half colon at the end of the getDrivers function and that I have a use strict statement at the top of the file. However, grunt refuses to run the application without both of these lines, so I don't think this could be a problem.
If anyone could point me in the right direction here, I would be very grateful.
source share