I am a beginner in learning angular 4 framework and have seen all the threads regarding this problem on stackoverflow but the solutions given in them not able to solve my problem.
I am getting this error "http://localhost:4200/src/assets/images/1.jpg 404 (Not Found)" .All other things are working fine but only image is not getting loaded. I am giving my .angular-cli.json code and my custom made component code where i given my img tag.
My custom component code:-
import { Component } from '@angular/core';
@Component({
selector:'my-comp',
template:`<button (mousemove)="clicked($event)">{{name1}}</button>
<div *ngIf="applyDiv==false">WTF</div>
<ul>
<li *ngFor="let i of a;let j=index">{{j}}.{{i}}</li>
</ul>
<img src="../../src/assets/images/1.jpg" alt="Ms dhoni" width="2000" height="2000"/>
<input type="text" name="Sahil" value="sahil"/>
<div [class.myClass]="myclass">Apply Class</div>
<div [style.color]="applyBlue?'blue':'yellow'">Starting Angualr</div>`,
styleUrls:['./hello.component.css']
})
export class HelloComponent {
name='Angular1';
myclass=true;
applyBlue=true;
name1=0;
applyDiv=false;
a=[1,'2','3iituit'];
clicked(event){
console.log(event.target);
this.name1++;
}
// name1:string="sahil";
//logo="../../assets/images/mov2.jpg";
}
My code .angular-cli.json:-
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "my-app"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets/images",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {
}
}
}
Can anyone tell me what is the problem here. Thanks in advance!!


src,srcfolder is the root of your app.http://localhost:4200/assets/images/1.jpg