I need to dynamically change the div's ng-style background?
div:
<div ng-style="{'background-image': 'url({{candidate.image}})'}">
{{candidate.name}}
</div>
controller:
angular.module("MyModule")
.controller("MyController", function($scope) {
$scope.candidate = {
"image" : "myurl.png",
"name" : "My Name"
};
$scope.changeCandidate = function() {
$scope.candidate = {
"image" : "anotherurl.png",
"name" : "Another Name"
};
};
});
When a button fires changeCandidate() function, the displayed name changed from My Name to Another Name but the background-image of ng-style remains the same