I have class named "tp-cont" which is loaded from a different .css file. I could change the background image using jQuery using the below code.
In HTML:
<li ng-click="changeTemplateBackgroundImage()"></li>
In Controller:
$scope.changeTemplateBackgroundImage = function(){
var imageUrl = 'public/uploads/Admin/template_themes/1/black.png';
$('.tp-cont').css('background-image','url(' + imageUrl + ')');
};
I want to know if there a work around for the same using angularjs
Thanks is advance.
Answer given below:
In Controller :
$scope.changeTemplateBackgroundImage = function(){
$scope.bgUrl = 'public/uploads/Admin/template_themes/1/black.png';
};
In HTML :
<div class="tp-cont" ng-style="{ 'background-image': 'url({{bgUrl}})' }">