Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Bug]: #270

Open
kscSoft opened this issue Sep 24, 2022 · 2 comments
Open

🐛 [Bug]: #270

kscSoft opened this issue Sep 24, 2022 · 2 comments

Comments

@kscSoft
Copy link

kscSoft commented Sep 24, 2022

Version

[email protected]

Angular Version

Angular: 12.2.16

Link to minimal reproduction

  • component.html
    <d-avatar [imgSrc]="headerImg">

  • component.ts
    headerImg;
    ngOnInit(): void {
    this._http.post(_api, {
    keyID: 2,
    }, {
    responseType: 'blob',
    }).subscribe((data) => {
    // const _blob = this._sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(data));
    const _src = URL.createObjectURL(data);
    this.headerImg = _src;
    });
    }

the headerImg cannot be displayed normally in d-avatar

Step to reproduce

  • component.html
    <d-avatar [imgSrc]="headerImg">

  • component.ts
    headerImg;
    ngOnInit(): void {
    this._http.post(_api, {
    keyID: 2,
    }, {
    responseType: 'blob',
    }).subscribe((data) => {
    // const _blob = this._sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(data));
    const _src = URL.createObjectURL(data);
    this.headerImg = _src;
    });
    }

the headerImg cannot be displayed normally in d-avatar

What is expected

No response

What is actually happening

No response

Any additional comments (optional)

No response

@EnochGao
Copy link
Contributor

EnochGao commented Sep 27, 2022

I tried it and it didn't happen again.your code should be this.headerImg= this._sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(data)); and make sure data is of type Blob. @kscSoft
demo

@kagol
Copy link
Member

kagol commented Oct 21, 2022

@kscSoft Thank you for your feedback. I hope the title of issue can be written clearly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants