I am getting profileImage
object in which sometime data(profileImage.url
) is present and sometimes not(null). How can i write turnary operator in ngStyle
so that if profileImage.url
is present then show it, other wise user.image
(in which common image url is present)
this is i tried
<div class="image-avatar"
[ngStyle]="{
'background-image': 'url(' + user.profileImage && user.profileImage.url ? user.profileImage.url : user.image + ')'
}">
</div>
and i am getting error Cannot read property 'url' of null