1

I would like to be able to manipulate some images around the screen but can't get it to work properly.

I'v tried using

$scope.data[i].style="{'width': '" + $scope.imageScale + "px'}"

in the controller, called when imageScale changes, with

<div class = "image" ng-repeat="image in data">
    <img ng-src={{image.Filename}} ng-style="image.style">
</div>

located in the HTML.

Thanks

1 Answer 1

2

Your controller code isn't going to bind the style property like you intend. This is only going to run once, and won't be updated when $scope.imageScale changes.

$scope.data[i].style="{'width': '" + $scope.imageScale + "px'}"

Instead, you can do:

<img ng-src={{image.Filename}} ng-style="{'width':$imageScale+'px'}">

Or:

<img ng-src={{image.Filename}} width="{{$imageScale}}">

Or:

<img ng-src={{image.Filename}} style="width:{{$imageScale}}px;">
Sign up to request clarification or add additional context in comments.

2 Comments

why doesn't this work with "top" and "bottom" css variables?
Method #1 or #3 should work that way. If you post your code I can give more detail.

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.