0

I'm getting this error ReferenceError: images is not defined when I set $scope.primaryImage = images[ii];

This code lives in one of my controllers:

$scope.findOne = function() {
    Items.get({
        itemId: $routeParams.itemId
    }, function(item) {
        $scope.item = item;

        for(var ii=0; ii < item.images.length; ii++){
            if(item.images[ii].primary)
                $scope.primaryImage = images[ii];
        }
        alert("hey");
    });
};

The schema that I'm passing looks like this:

var ItemSchema = new Schema({ images: [ImageSchema]});

And ImageSchema looks like:

var ImageSchema = new Schema({primay: {type: Boolean, default: false}});

I'm very new to angular so let me know if you need more information from me.

1
  • $scope.primaryImage = item.images[ii]; instead of $scope.primaryImage = images[ii]; Commented Dec 22, 2013 at 3:48

1 Answer 1

1

Looks to me like there is no variable 'images' defined, but rather a property of 'item'.

Sign up to request clarification or add additional context in comments.

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.