Images not loading in Angular 2

If you are using angular-cli then all your static assets should be kept in assets folder. Then you should give path as

 <div>
      <img  src="assets/images/New-Google-Logo.png"/>
 </div>

When you serve the project all static assets needs to be served to client in order to display it on client. Angular cli build and bundle entire project in js files. To serve your static assets you can follow two ways

  • put all your static assets in assets folder which angular-cli serves with default .angular-cli.json
  • or you need to make entry of the static assets folder in .angular-cli.json file in array named as assets as my images folder is in static folder and static folder is at same hierarchy level of assets folder

    "assets": [ "assets", "static/images" ]
    

Tags:

Html

Css

Angular