0

I'm trying to update a div with an image and a link when a certain function is called and updates the imagesobject.

Here's what I have:

<a ng-bind="images[0]" ng-href="{{images[0].link}}"><img ng-bind="images[0]" ng-src="{{images[0].url || '' }}"></a>

On the controller:

$scope.upload = function (file, pos) {
    $scope.images[parseInt(pos)] = file;
    $scope.images[parseInt(pos)].url = 'http://i.imgur.com/ik9xqXp.jpg?1'
};

This function is called when the user submits an image.

However, when the images object updates, instead of an image, I get the string "[object File]

What am I doing wrong?

6
  • Could you please show the controller where you are updating the images object Commented Feb 22, 2016 at 17:06
  • It looks like just a ReferenceError. You want to access certain data but is accessing another instead, as @NagaSandeep said, give us a little bit of code as example. Commented Feb 22, 2016 at 17:08
  • Are you sure images[0].url returns a string? Commented Feb 22, 2016 at 17:14
  • I edited my post with the controller method that updates the images array Commented Feb 22, 2016 at 17:15
  • 1
    Also, why are you using ng-bind - I'm pretty sure ng-src does two-way binding already. Commented Feb 22, 2016 at 17:18

1 Answer 1

2

Remove ng-bind and just use ng-src. ng-src already handles two-way binding.

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.