Click here to Skip to main content
15,889,992 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 {

imgPath:string='E:/Angular/DailyReportAnalysis/src/assets/Images/rkjet.jpg';
  constructor() { }

  ngOnInit() {
  }

}


and html

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

What I have tried:

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

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