質問編集履歴
5
誤字
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
angular5で画像表示をしたいのですができません。
|
|
4
4
|
何故でしょうか。初心者の質問でお手数をおかけします。
|
|
5
|
-
``<img src="./assets/bird.png">``の書き方はangular5ではダメということでしょうか?
|
|
5
|
+
``<img src="./assets/bird.png">``の書き方はangular5.2.11ではダメということでしょうか?
|
|
6
6
|
|
|
7
7
|
### 発生している問題・エラーメッセージ
|
|
8
8
|
|
4
文法修正
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
### 試したこと
|
|
22
|
-
|
|
22
|
+
0. 「ng new test-app」実行
|
|
23
|
-
|
|
23
|
+
0. 「assets」フォルダに「bird.png」を格納
|
|
24
|
-
|
|
24
|
+
0. 失敗
|
|
25
|
-
|
|
25
|
+
「index.html」に``<img src="./assets/bird.png">``を追記
|
|
26
|
-
|
|
26
|
+
0. 成功
|
|
27
|
-
|
|
27
|
+
・「app.component.html」に``<div class="wall"></div>``を追記
|
|
28
|
-
|
|
28
|
+
・「app.component.css」に
|
|
29
29
|
``.wall {
|
|
30
30
|
background-image: url(../assets/bird.png);
|
|
31
31
|
width: 100%;
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
background-position: 50% 50%;
|
|
40
40
|
background-attachment:fixed;
|
|
41
41
|
}``を追記
|
|
42
|
-
|
|
42
|
+
0. 成功
|
|
43
|
-
|
|
43
|
+
・「app.component.html」に``<img [src]="path">``を追記
|
|
44
|
-
|
|
44
|
+
・「app.component.ts」に
|
|
45
45
|
``export class AppComponent {
|
|
46
46
|
title = 'app';
|
|
47
47
|
path = require('assets/bird.png');
|
|
48
48
|
}``を記載
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
### 補足情報(FW/ツールのバージョンなど)
|
|
51
51
|
OS:windows10
|
|
52
52
|
画像の絶対パス:「test-app\src\assets\bird.png」
|
3
試したことを追記
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
angular5で画像表示をしたいのですができません。
|
|
4
4
|
何故でしょうか。初心者の質問でお手数をおかけします。
|
|
5
|
+
``<img src="./assets/bird.png">``の書き方はangular5ではダメということでしょうか?
|
|
5
6
|
|
|
6
7
|
### 発生している問題・エラーメッセージ
|
|
7
8
|
|
|
@@ -18,14 +19,38 @@
|
|
|
18
19
|
```
|
|
19
20
|
|
|
20
21
|
### 試したこと
|
|
21
|
-
|
|
22
22
|
1.「ng new test-app」実行
|
|
23
23
|
2.「assets」フォルダに「bird.png」を格納
|
|
24
|
+
3.失敗
|
|
24
|
-
|
|
25
|
+
・「index.html」に``<img src="./assets/bird.png">``を追記
|
|
25
|
-
|
|
26
|
+
4. 成功
|
|
27
|
+
・「app.component.html」に``<div class="wall"></div>``を追記
|
|
28
|
+
・「app.component.css」に
|
|
29
|
+
``.wall {
|
|
30
|
+
background-image: url(../assets/bird.png);
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
margin: 0;
|
|
34
|
+
padding: 0;
|
|
35
|
+
top: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
position: absolute;
|
|
38
|
+
background-repeat: no-repeat;
|
|
39
|
+
background-position: 50% 50%;
|
|
40
|
+
background-attachment:fixed;
|
|
41
|
+
}``を追記
|
|
42
|
+
5 成功
|
|
43
|
+
・「app.component.html」に``<img [src]="path">``を追記
|
|
44
|
+
・「app.component.ts」に
|
|
45
|
+
``export class AppComponent {
|
|
46
|
+
title = 'app';
|
|
47
|
+
path = require('assets/bird.png');
|
|
48
|
+
}``を記載
|
|
49
|
+
|
|
26
50
|
### 補足情報(FW/ツールのバージョンなど)
|
|
27
51
|
OS:windows10
|
|
28
52
|
画像の絶対パス:「test-app\src\assets\bird.png」
|
|
53
|
+

|
|
29
54
|
AngularCLI:1.7.4
|
|
30
55
|
``{
|
|
31
56
|
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
2
OS、画像の絶対パスを追記
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
3.「index.html」に「<img src="./assets/bird.png">」を追記
|
|
25
25
|
|
|
26
26
|
### 補足情報(FW/ツールのバージョンなど)
|
|
27
|
+
OS:windows10
|
|
28
|
+
画像の絶対パス:「test-app\src\assets\bird.png」
|
|
27
|
-
|
|
29
|
+
AngularCLI:1.7.4
|
|
28
|
-
``
|
|
30
|
+
``{
|
|
29
|
-
{
|
|
30
31
|
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
31
32
|
"project": {
|
|
32
33
|
"name": "test-app"
|
|
@@ -85,5 +86,4 @@
|
|
|
85
86
|
"styleExt": "css",
|
|
86
87
|
"component": {}
|
|
87
88
|
}
|
|
88
|
-
}
|
|
89
|
-
``
|
|
89
|
+
}``
|
1
ngular CLIのバージョンと.angular-cli.jsonまたはangular.jsonの内容を追記しました。
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -24,5 +24,66 @@
|
|
|
24
24
|
3.「index.html」に「<img src="./assets/bird.png">」を追記
|
|
25
25
|
|
|
26
26
|
### 補足情報(FW/ツールのバージョンなど)
|
|
27
|
-
|
|
27
|
+
Angular CLIのバージョンは 1.7.4です。
|
|
28
|
+
``
|
|
29
|
+
{
|
|
30
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
31
|
+
"project": {
|
|
32
|
+
"name": "test-app"
|
|
33
|
+
},
|
|
34
|
+
"apps": [
|
|
35
|
+
{
|
|
36
|
+
"root": "src",
|
|
37
|
+
"outDir": "dist",
|
|
38
|
+
"assets": [
|
|
39
|
+
"assets",
|
|
40
|
+
"favicon.ico"
|
|
41
|
+
],
|
|
42
|
+
"index": "index.html",
|
|
43
|
+
"main": "main.ts",
|
|
44
|
+
"polyfills": "polyfills.ts",
|
|
45
|
+
"test": "test.ts",
|
|
46
|
+
"tsconfig": "tsconfig.app.json",
|
|
47
|
+
"testTsconfig": "tsconfig.spec.json",
|
|
48
|
+
"prefix": "app",
|
|
49
|
+
"styles": [
|
|
50
|
+
"styles.css"
|
|
51
|
+
],
|
|
52
|
+
"scripts": [],
|
|
53
|
+
"environmentSource": "environments/environment.ts",
|
|
54
|
+
"environments": {
|
|
55
|
+
"dev": "environments/environment.ts",
|
|
56
|
+
"prod": "environments/environment.prod.ts"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"e2e": {
|
|
61
|
+
"protractor": {
|
|
62
|
+
"config": "./protractor.conf.js"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"lint": [
|
|
66
|
+
{
|
|
67
|
+
"project": "src/tsconfig.app.json",
|
|
68
|
+
"exclude": "**/node_modules/**"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"project": "src/tsconfig.spec.json",
|
|
72
|
+
"exclude": "**/node_modules/**"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"project": "e2e/tsconfig.e2e.json",
|
|
76
|
+
"exclude": "**/node_modules/**"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"test": {
|
|
28
|
-
|
|
80
|
+
"karma": {
|
|
81
|
+
"config": "./karma.conf.js"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"defaults": {
|
|
85
|
+
"styleExt": "css",
|
|
86
|
+
"component": {}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
``
|