Translate

22 Temmuz 2016 Cuma

ng-style background-image with angular


<div class="Table-row-item rowHas_img">
    <div class="table_row_Img" ng-style="getBackgroundStyle(data.sex)"></div>
</div>



$scope.getBackgroundStyle = function(gender) {
    var imagepath = 'https://s3.amazonaws.com/37assets/svn/1065-IMG_2529.jpg';

    if (gender === 'M')
        imagepath = 'http://pis.net.in/wp-content/uploads/2015/04/man1.png ';
    else if (gender === 'F') {
        imagepath = 'http://www.freeiconspng.com/uploads/female-icon-27.png';
    }
    return {
        'background-image': 'url(' + imagepath + ')'
    }
}

Hiç yorum yok:

Yorum Gönder

Bu Blogda Ara