Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Bind style background image to model #10190


User avatar
0
rvanwoezik created

ASP.NET CORE & Angular (single solution) .NET 5.0 v10.2.0

I want to bind the style background image to angular model by:

<div class="image-input image-input-empty image-input-outline" id="kt_user_edit_avatar" [style.background-image]="'url(' + course.courseImageUrl + ')'">

But it doesn't show the image, when i use: <img [src]="course.courseImageUrl"/> the image is visible

Image is set by this:

setCourseImageUrl(course: CourseListDto): void {
        this._localStorageService.getItem(AppConsts.authorization.encrptedAuthTokenName,
            function(err, value) {
               let courseImageUrl = AppConsts.remoteServiceBaseUrl +
                    '/Course/GetCourseImageByCourse?courseId=' +
                    course.id +
                    '&' +
                    AppConsts.authorization.encrptedAuthTokenName +
                    '=' +
                    encodeURIComponent(value.token);
               (course as any).courseImageUrl = courseImageUrl;

            });
    }

1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @rvanwoezik

    This is not related to AspNet Zero but I think you should provide dimensions (width, height) to the related div.