0

I am applying code to my project run by this guy https://github.com/simpulton/angular-photo-slider/blob/master/js/app.js. He has a little syntax error already, and the console tells you about it, but after I fixed it the console just gives the vague "SyntaxError: syntax error" message. Here's what I've been trying to do:

var app = angular.module('LOC Search', ['ngAnimate']);

app.controller('locListCtrl', ['$scope', function ($scope, $http)) {
$http.jsonp('http://loc.gov/pictures/collections?fo=json&callback=process=JSON_CALLBACK').success(function(data) {

$scope.slides = data.collections;

}
}]);

Does anyone have any suggestions? Also, different version of AngularJS will produce different results... Not sure which one to use with this particular example. THANKS!

0

2 Answers 2

1

You have double parentheses at places and some are missing.

Try this:

var app = angular.module('LOC Search', ['ngAnimate']);

app.controller('locListCtrl', ['$scope', '$http', function ($scope, $http) {
    $http.jsonp('http://loc.gov/pictures/collections?fo=json&callback=process=JSON_CALLBACK').success(function(data) {

        $scope.slides = data.collections;

    });
}]);
Sign up to request clarification or add additional context in comments.

Comments

0

you forgot to inject the $http service.

try:

app.controller('locListCtrl', ['$scope', '$http', function ($scope, $http) {
   ...

or you can also do:

app.controller('locListCtrl', function ($scope, $http) {
    ...

but the second one is much less recommended, because the code won't work if you minify the code.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.