#how can I get src value from img in my component.ts file
4 messages · Page 1 of 1 (latest)
When using Angular, the HTML is generated based on the model. So the src should come from some data in your TypeScript code already.
In here, there is a solution.
But why, when you could simply do
@Component({
template: '<img [src]="imageUrl"/>'
// ...
})
class MyComponent {
imageUrl = 'https://example.com/my-image.jpg';
}