html - angularjs background image not working on span tag -
i'm trying apply background image span tag using angular ng-style , when span tag clicked calls chgimg doesn't seem working. working if directly replacing {{img}} /images/chk.svg
<span ng-style="{'background-image':'url({{img}})'}" ng-click="chgimg()" class="pollchoice--radio">{{img}} </span> angularcode:
app.controller('homectrl', ['$scope', 'posts', function($scope, posts) { $scope.posts = posts.posts; $scope.chgimg = function(){ $scope.img = "/images/chk.svg"; }; } ]);
please use $scope.apply below:
$scope.chgimg = function(){ $scope.$apply(function () { $scope.img = "/images/chk.svg"; }); };
Comments
Post a Comment