Click here to Skip to main content
15,944,733 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: (untagged)
Here is my ts file

export class HomeComponent implements OnInit {

  constructor() { }

  ngOnInit() {


and html

<div >
<img [src]="imgPath">

What I have tried:

I have also given direct path to the image source but it didn't work
Updated 9-Jun-17 6:39am

1 solution

You are trying to load an image from the user's local disk. Web pages are not permitted to do that, as it would be a security risk.

If you're trying to load an image from your server, then you need to use a valid URL. For example:
imgPath:string = '/assets/Images/rkjet.jpg';
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900