L
L
Lenar Mutigullin2016-11-23 14:55:08
Angular
Lenar Mutigullin, 2016-11-23 14:55:08

How to get an image using Get requests?

there is an ip, there is an image, how can I get it and display it on the page?
I'm trying to do this, but it doesn't work:
service

getCategoryLogo(id: number) {
        this.categoryLogoUrl=this.categoryLogoUrl+'/'+id+'/logo';
        return this.http.get(this.categoryLogoUrl, {headers: this.headers})
    }

component
getCategoryLogo(id: number){
        this.categoryService.getCategoryLogo(id)
            .subscribe(
                categoryLogo => this.categoryLogo = categoryLogo
            )
    }

html
<img src='getCategoryLogo(category.id)' alt="logo">

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Kayun, 2016-11-23
@NardM

http.get returns Observable from rxjs. This object has corresponding methods, you can subscribe to it.
Here is an example https://angular.io/docs/ts/latest/guide/server-com...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question