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

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -