{"id":7521,"date":"2017-04-06T15:58:58","date_gmt":"2017-04-06T06:58:58","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=7521"},"modified":"2017-04-09T01:17:27","modified_gmt":"2017-04-08T16:17:27","slug":"angular2%e3%81%ae%e5%a7%8b%e3%82%81%e6%96%b9%e3%80%82angular2-%e5%85%ac%e5%bc%8f%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab-routing%ef%bc%88%e7%b0%a1%e5%8d%98%e3%81%aa%e5%92%8c","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=7521","title":{"rendered":"Angular2\u306e\u59cb\u3081\u65b9\u3002Angular2 \u516c\u5f0f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb &#8211; Routing\uff08\u7c21\u5358\u306a\u548c\u8a33\uff09"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2016\/12\/angular_routing.png\" alt=\"\" width=\"600\" height=\"300\" class=\"alignnone size-full wp-image-7759\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2016\/12\/angular_routing.png 600w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2016\/12\/angular_routing-300x150.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<h4>ROUTING<\/h4>\n<p>\u3053\u3061\u3089\u306e\u30da\u30fc\u30b8\u306f\u3001\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u306e\u7c21\u5358\u306a\u548c\u8a33\u3067\u3059\u3002<\/p>\n<p><a href=\"https:\/\/angular.io\/docs\/ts\/latest\/tutorial\/toh-pt5.html\" target=\"_blank\">Angular2 tutorial | ROUTING<\/a><\/p>\n<p><strong>\u524d\u56de<\/strong><br \/>\n<a href=\"https:\/\/www.webcyou.com\/?p=7519\">Angular2\u306e\u59cb\u3081\u65b9\u3002Angular2 \u516c\u5f0f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb \u2013 Services\uff08\u7c21\u5358\u306a\u548c\u8a33\uff09<\/a><\/p>\n<p><strong>\u305d\u306e\u4ed6<\/strong><\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/?p=7515\">Angular2\u306e\u59cb\u3081\u65b9\u3002Angular2 \u516c\u5f0f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb \u2013 Multiple Components\uff08\u7c21\u5358\u306a\u548c\u8a33\uff09<\/a><\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/?p=7512\">Angular2\u306e\u59cb\u3081\u65b9\u3002Angular2 \u516c\u5f0f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb \u2013 Master\/Detail\uff08\u7c21\u5358\u306a\u548c\u8a33\uff09<\/a><\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/?p=7507\">Angular2\u306e\u59cb\u3081\u65b9\u3002Angular2 \u516c\u5f0f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb \u2013 SETUP FOR LOCAL DEVELOPMENT\uff08\u7c21\u5358\u306a\u548c\u8a33\uff09Angular2\u306e\u59cb\u3081\u65b9\u3002Angular2 \u516c\u5f0f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb \u2013 Introduction\uff08\u7c21\u5358\u306a\u548c\u8a33\uff09<\/a><\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/?p=7510\">Angular2\u306e\u59cb\u3081\u65b9\u3002Angular2 \u516c\u5f0f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb \u2013 The Hero Editor\uff08\u7c21\u5358\u306a\u548c\u8a33\uff09<\/a><\/p>\n<p>\u30d2\u30fc\u30ed\u30fc\u30ba\u30c4\u30a2\u30fc\u306e\u65b0\u3057\u3044\u8981\u4ef6\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n<p>\u30fb \u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u30d3\u30e5\u30fc\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb Heroes\u30d3\u30e5\u30fc\u3068Dashboard\u30d3\u30e5\u30fc\u306e\u9593\u3092\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308b\u6a5f\u80fd\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u3044\u305a\u308c\u304b\u306e\u30d3\u30e5\u30fc\u3067\u30e6\u30fc\u30b6\u30fc\u304c\u30d2\u30fc\u30ed\u30fc\u540d\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u9078\u629e\u3057\u305f\u30d2\u30fc\u30ed\u30fc\u306e\u8a73\u7d30\u30d3\u30e5\u30fc\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u30e6\u30fc\u30b6\u30fc\u304c\u96fb\u5b50\u30e1\u30fc\u30eb\u306e\u30c7\u30a3\u30fc\u30d7\u30ea\u30f3\u30af\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u7279\u5b9a\u306e\u30d2\u30fc\u30ed\u30fc\u306e\u8a73\u7d30\u30d3\u30e5\u30fc\u304c\u958b\u304d\u307e\u3059\u3002<\/p>\n<p>\u5b8c\u4e86\u3057\u305f\u3089\u3001\u30e6\u30fc\u30b6\u30fc\u306f\u6b21\u306e\u3088\u3046\u306b\u30a2\u30d7\u30ea\u3092\u30ca\u30d3\u30b2\u30fc\u30c8\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/04\/nav-diagram.png\" alt=\"\" width=\"506\" height=\"433\" class=\"alignnone size-full wp-image-7766\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/04\/nav-diagram.png 506w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/04\/nav-diagram-300x257.png 300w\" sizes=\"auto, (max-width: 506px) 100vw, 506px\" \/><\/p>\n<p>\u3053\u308c\u3089\u306e\u8981\u4ef6\u3092\u6e80\u305f\u3059\u305f\u3081\u306b\u3001\u30a2\u30d7\u30ea\u306bAngular\u306e\u30eb\u30fc\u30bf\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>&#8220;&#8220;&#8220;<br \/>\n\u30eb\u30fc\u30bf\u306e\u8a73\u7d30\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html\" target=\"_blank\">Routing and Navigation\u30da\u30fc\u30b8<\/a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n&#8220;&#8220;&#8220;<\/p>\n<p>\u3053\u306e\u30da\u30fc\u30b8\u304c\u7d42\u4e86\u3057\u305f\u3089\u3001\u30a2\u30d7\u30ea\u306f\u3001<a href=\"https:\/\/angular.io\/resources\/live-examples\/toh-5\/ts\/eplnkr.html\" target=\"_blank\">live example<\/a> \/ <a href=\"https:\/\/angular.io\/resources\/zips\/toh-5\/toh-5.zip\" target=\"_blank\">downloadable example.<\/a> \u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>&#8220;&#8220;&#8220;<br \/>\n\u30e9\u30a4\u30d6\u30b5\u30f3\u30d7\u30eb\u306e\u30d6\u30e9\u30a6\u30b6\u306e\u30a2\u30c9\u30ec\u30b9\u30d0\u30fc\u3067URL\u306e\u5909\u66f4\u3092\u78ba\u8a8d\u3059\u308b\u306b\u306f\u3001\u53f3\u4e0a\u306e\u30a2\u30a4\u30b3\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066Plunker\u30a8\u30c7\u30a3\u30bf\u3067\u3082\u3046\u4e00\u5ea6\u958b\u304d\u3001\u53f3\u4e0a\u9685\u306e\u9752\u3044\u300cX\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u30d7\u30ec\u30d3\u30e5\u30fc\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u958b\u304d\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/04\/plunker-switch-to-editor-button.png\" alt=\"\" width=\"282\" height=\"99\" class=\"alignnone size-full wp-image-7767\" \/><br \/>\n&#8220;&#8220;&#8220;<\/p>\n<h4>Where you left off<\/h4>\n<p>\u30d2\u30fc\u30ed\u30fc\u30c4\u30a2\u30fc\u306b\u9032\u3080\u524d\u306b\u3001\u4ee5\u4e0b\u306e\u69cb\u9020\u3092\u6301\u3063\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">angular-tour-of-heroes\r\n\u251c\u2500\u2500src\r\n\u2502 \u251c\u2500\u2500app\r\n\u2502 \u2502  \u251c\u2500\u2500app.component.ts\r\n\u2502 \u2502  \u251c\u2500\u2500app.module.ts\r\n\u2502 \u2502  \u251c\u2500\u2500hero.ts\r\n\u2502 \u2502  \u251c\u2500\u2500hero-detail.component.ts\r\n\u2502 \u2502  \u251c\u2500\u2500hero.service.ts\r\n\u2502 \u2502  \u2514\u2500\u2500mock-heroes.ts\r\n\u2502 \u251c\u2500\u2500main.ts\r\n\u2502 \u251c\u2500\u2500index.html\r\n\u2502 \u251c\u2500\u2500styles.css\r\n\u2502 \u251c\u2500\u2500systemjs.config.js\r\n\u2502 \u2514\u2500\u2500tsconfig.json\r\n\u251c\u2500\u2500node_modules ...\r\n\u2514\u2500\u2500package.json<\/pre>\n<h4>Keep the app transpiling and running<\/h4>\n<p>\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ npm start<\/pre>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3001&#8221;watch mode&#8221;\u3067\u3001TypeScript\u30b3\u30f3\u30d1\u30a4\u30e9\u3092\u5b9f\u884c\u3057\u3001\u30b3\u30fc\u30c9\u304c\u5909\u66f4\u3055\u308c\u305f\u3068\u304d\u306b\u81ea\u52d5\u7684\u306b\u518d\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3001\u30d6\u30e9\u30a6\u30b6\u3067\u30a2\u30d7\u30ea\u3092\u540c\u6642\u306b\u8d77\u52d5\u3057\u3001\u30b3\u30fc\u30c9\u304c\u5909\u66f4\u3055\u308c\u305f\u3068\u304d\u306b\u30d6\u30e9\u30a6\u30b6\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d6\u30e9\u30a6\u30b6\u3092\u518d\u30b3\u30f3\u30d1\u30a4\u30eb\u307e\u305f\u306f\u66f4\u65b0\u3059\u308b\u305f\u3081\u306b\u4e00\u6642\u505c\u6b62\u3059\u308b\u3053\u3068\u306a\u304f\u3001\u30d2\u30fc\u30ed\u30fc\u306e\u30c4\u30a2\u30fc\u3092\u69cb\u7bc9\u3057\u7d9a\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h4>Action plan<\/h4>\n<p>\u8a08\u753b\u306f\u6b21\u306e\u901a\u308a\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30fb <strong>AppComponent<\/strong>\u3092\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u306e\u307f\u3092\u51e6\u7406\u3059\u308b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b7\u30a7\u30eb\u306b\u5909\u63db\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u73fe\u5728\u306e<strong>AppComponent<\/strong>\u5185\u306e<strong>Heroes<\/strong>\u306e\u61f8\u5ff5\u4e8b\u9805\u3092\u3001\u5225\u306e<strong>HeroesComponent<\/strong>\u306b\u518d\u914d\u7f6e\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u65b0\u3057\u3044<strong>DashboardComponent<\/strong>\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u3092\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u69cb\u9020\u306b\u7d50\u3073\u4ed8\u3051\u307e\u3059\u3002<\/p>\n<p>&#8220;&#8220;&#8220;<br \/>\n\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306f\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u306e\u5225\u306e\u540d\u524d\u3067\u3059\u3002\u30eb\u30fc\u30bf\u306f\u3001\u30d3\u30e5\u30fc\u304b\u3089\u30d3\u30e5\u30fc\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308b\u305f\u3081\u306e\u30e1\u30ab\u30cb\u30ba\u30e0\u3067\u3059\u3002<br \/>\n&#8220;&#8220;&#8220;<\/p>\n<h4>Splitting the AppComponent<\/h4>\n<p>\u73fe\u5728\u306eApp\u306f\u3001<strong>AppComponent<\/strong>\u3092\u30ed\u30fc\u30c9\u3057\u3001\u3059\u3050\u306b\u30d2\u30fc\u30ed\u30fc\u306e\u30ea\u30b9\u30c8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u4fee\u6b63\u3055\u308c\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u30d3\u30e5\u30fc\u306e\u9078\u629e\u80a2\u3092\u6301\u3064\u30b7\u30a7\u30eb\uff08\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u3068\u30d2\u30fc\u30ed\u30fc\u30ba\uff09\u3092\u8868\u793a\u3057\u3001\u305d\u306e\u3046\u3061\u306e1\u3064\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u3092\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><strong>AppComponent<\/strong>\u306f\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u306e\u307f\u3092\u51e6\u7406\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001Hero\u306e\u8868\u793a\u3092<strong>AppComponent<\/strong>\u304b\u3089<strong>HeroesComponent<\/strong>\u306b\u79fb\u52d5\u3057\u307e\u3059<\/p>\n<h5>HeroesComponent<\/h5>\n<p>AppComponent\u306f\u3059\u3067\u306bHeroes\u5c02\u7528\u3067\u3059\u3002 <\/p>\n<p>AppComponent\u304b\u3089\u30b3\u30fc\u30c9\u3092\u79fb\u52d5\u3059\u308b\u4ee3\u308f\u308a\u306b\u3001<strong>HeroesComponent<\/strong>\u306e\u540d\u524d\u3092\u5909\u66f4\u3057\u3001\u5225\u306eAppComponent\u30b7\u30a7\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306e\u64cd\u4f5c\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>\u30fb <strong>app.component.ts<\/strong>\u30d5\u30a1\u30a4\u30eb\u306e\u540d\u524d\u3092<strong>heroes.component.ts<\/strong>\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb <strong>AppComponent<\/strong>\u30af\u30e9\u30b9\u306e\u540d\u524d\u3092<strong>HeroesComponent<\/strong>\u306b\u5909\u66f4\u3057\u307e\u3059\uff08\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u5185\u3067\u306e\u307f\u30ed\u30fc\u30ab\u30eb\u306b\u540d\u524d\u3092\u5909\u66f4\u3057\u307e\u3059\uff09\u3002<\/p>\n<p>\u30fb \u30bb\u30ec\u30af\u30bf<strong>my-app<\/strong>\u306e\u540d\u524d\u3092\u3001<strong>my-heroes<\/strong>\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/heroes.component.ts (showing renamings only)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">@Component({\r\n  selector: 'my-heroes',\r\n})\r\nexport class HeroesComponent implements OnInit {\r\n}<\/pre>\n<h5>Create AppComponent<\/h5>\n<p>\u65b0\u3057\u3044 <strong>AppComponent<\/strong>\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b7\u30a7\u30eb\u3067\u3059\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u304c\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308b\u30da\u30fc\u30b8\u306e\u4e0a\u90e8\u306b\u306f\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30ea\u30f3\u30af\u304c\u3001\u4e0b\u90e8\u306b\u306f\u8868\u793a\u9818\u57df\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306e\u624b\u9806\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>src \/ app \/ app.component.ts\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/li>\n<li>\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3055\u308c\u305f <strong>AppComponent<\/strong>\u30af\u30e9\u30b9\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/li>\n<li>my-app\u30bb\u30ec\u30af\u30bf\u3092\u4f7f\u7528\u3057\u3066\u3001\u30af\u30e9\u30b9\u306e\u4e0a\u306b@Component\u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/li>\n<li>HeroesComponent\u304b\u3089\u3001AppComponent\u306b\u6b21\u306e\u9805\u76ee\u3092\u79fb\u52d5\u3057\u307e\u3059\u3002\n<ul>\n<li>\u30bf\u30a4\u30c8\u30eb\u30af\u30e9\u30b9\u30d7\u30ed\u30d1\u30c6\u30a3\u3002<\/li>\n<li>@Component\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8&lt;h1&gt;\u8981\u7d20\u3002\u30bf\u30a4\u30c8\u30eb\u3078\u306e\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u898b\u51fa\u3057\u306e\u3059\u3050\u4e0b\u306e\u30a2\u30d7\u30ea\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u3001&lt;my-heroes&gt;\u8981\u7d20\u3092\u8ffd\u52a0\u3059\u308b\u3068\u3001\u307e\u3060\u30d2\u30fc\u30ed\u30fc\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/li>\n<li>AppModule\u306e\u5ba3\u8a00\u914d\u5217\u306bHeroesComponent\u3092\u8ffd\u52a0\u3059\u308b\u3068\u3001Angular\u306f\u3001 &lt;my-heroes&gt;\u30bf\u30b0\u3092\u8a8d\u8b58\u3057\u307e\u3059\u3002<\/li>\n<li>\u4ed6\u306e\u3059\u3079\u3066\u306e\u30d3\u30e5\u30fc\u3067<strong>HeroService<\/strong>\u304c\u5fc5\u8981\u306b\u306a\u308b\u305f\u3081\u3001<strong>HeroService<\/strong>\u3092<strong>AppModule<\/strong>\u306e\u30d7\u30ed\u30d0\u30a4\u30c0\u914d\u5217\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/li>\n<li><strong>HeroService<\/strong>\u30d7\u30ed\u30d0\u30a4\u30c0\u304c\u6607\u683c\u3055\u308c\u3066\u304b\u3089\u3001<strong>HeroService<\/strong>\u30d7\u30ed\u30d0\u30a4\u30c0\u914d\u5217\u304b\u3089\u3001HeroService\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/li>\n<li><strong>AppComponent<\/strong>\u306e\u30b5\u30dd\u30fc\u30c8\u3059\u308b\u30a4\u30f3\u30dd\u30fc\u30c8\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<p>\u6700\u521d\u306e\u30c9\u30e9\u30d5\u30c8\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app.components.ts(v1)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import { Component } from '@angular\/core';\r\n@Component({\r\n  selector: 'my-app',\r\n  template: `\r\n    &lt;h1&gt;{{title}}&lt;\/h1&gt;\r\n    &lt;my-heroes&gt;&lt;\/my-heroes&gt;\r\n  `\r\n})\r\nexport class AppComponent {\r\n  title = 'Tour of Heroes';\r\n}<\/pre>\n<p><strong>src\/app\/app.module.ts(v1)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import { NgModule }       from '@angular\/core';\r\nimport { BrowserModule }  from '@angular\/platform-browser';\r\nimport { FormsModule }    from '@angular\/forms';\r\nimport { AppComponent }        from '.\/app.component';\r\nimport { HeroDetailComponent } from '.\/hero-detail.component';\r\nimport { HeroesComponent }     from '.\/heroes.component';\r\nimport { HeroService }         from '.\/hero.service';\r\n@NgModule({\r\n  imports: &#x5B;\r\n    BrowserModule,\r\n    FormsModule\r\n  ],\r\n  declarations: &#x5B;\r\n    AppComponent,\r\n    HeroDetailComponent,\r\n    HeroesComponent\r\n  ],\r\n  providers: &#x5B;\r\n    HeroService\r\n  ],\r\n  bootstrap: &#x5B; AppComponent ]\r\n})\r\nexport class AppModule {\r\n}<\/pre>\n<p>\u30a2\u30d7\u30ea\u306f\u307e\u3060\u5b9f\u884c\u3055\u308c\u3001\u82f1\u96c4\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<h4>Adding routing<\/h4>\n<p>\u81ea\u52d5\u7684\u306b\u8868\u793a\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u5f8c\u306b\u30d2\u30fc\u30ed\u30fc\u304c\u8868\u793a\u3055\u308c\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<p>\u8a00\u3044\u63db\u3048\u308c\u3070\u3001\u30e6\u30fc\u30b6\u30fc\u306f\u30d2\u30fc\u30ed\u30fc\u306e\u30ea\u30b9\u30c8\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3067\u304d\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u3092\u6709\u52b9\u306b\u3059\u308b\u306b\u306f\u3001<strong>Angular router<\/strong>\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p><strong>Angular router<\/strong>\u306f\u3001<strong>RouterModule<\/strong>\u3068\u547c\u3070\u308c\u308b\u5916\u90e8\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306e<strong>Angular NgModule<\/strong>\u3067\u3059\u3002<\/p>\n<p>\u30eb\u30fc\u30bf\u306f\u3001\u8907\u6570\u306e\u63d0\u4f9b\u30b5\u30fc\u30d3\u30b9\uff08<strong>RouterModule<\/strong>\uff09\u3001\u8907\u6570\u306e\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\uff08<strong>RouterOutlet<\/strong>\u3001<strong>RouterLink<\/strong>\u3001<strong>RouterLinkActive<\/strong>\uff09\u3068\u69cb\u6210\uff08<strong>Routes<\/strong>\uff09\u306e\u7d44\u307f\u5408\u308f\u305b\u3067\u3059\u3002<\/p>\n<p>\u6700\u521d\u306b\u7d4c\u8def\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h5>&lt;base href&gt;<\/h5>\n<p>index.html\u3092\u958b\u304d\u3001&lt;head&gt;\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u4e0a\u90e8\u306b&lt;base href = &#8220;&#8230;&#8221;&gt;\u8981\u7d20\uff08\u307e\u305f\u306f\u3053\u306e\u8981\u7d20\u3092\u52d5\u7684\u306b\u8a2d\u5b9a\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\uff09\u304c\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/index.html (base-href)<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;head&gt;\r\n  &lt;base href=&quot;\/&quot;&gt;<\/pre>\n<p><strong>BASE HREF IS ESSENTIAL<\/strong><\/p>\n<p>&#8220;&#8220;&#8220;<br \/>\n\u8a73\u7d30\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html\" target=\"_blank\">Routing and Navigation<\/a>\u30da\u30fc\u30b8\u306e\u300c<a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html#!#base-href\" target=\"_blank\">Set the base href<\/a>\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n&#8220;&#8220;&#8220;<\/p>\n<h5>Configure routes<\/h5>\n<p>\u30a2\u30d7\u30ea\u30eb\u30fc\u30c8\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u30eb\u30fc\u30c8\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30ea\u30f3\u30af\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u304b\u3001URL\u3092\u30d6\u30e9\u30a6\u30b6\u306e\u30a2\u30c9\u30ec\u30b9\u30d0\u30fc\u306b\u8cbc\u308a\u4ed8\u3051\u308b\u3068\u304d\u306b\u8868\u793a\u3059\u308b\u30d3\u30e5\u30fc\u3092\u30eb\u30fc\u30bf\u30fc\u306b\u6307\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u6700\u521d\u306e\u30eb\u30fc\u30c8\u3092\u3001\u30d2\u30fc\u30ed\u30fc\u30ba\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3078\u306e\u30eb\u30fc\u30c8\u3068\u3057\u3066\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app.module.ts (heroes route)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import { RouterModule }   from '@angular\/router';\r\n\r\nRouterModule.forRoot(&#x5B;\r\n  {\r\n    path: 'heroes',\r\n    component: HeroesComponent\r\n  }\r\n])<\/pre>\n<p>\u30eb\u30fc\u30c8\u306f\u3001\u30eb\u30fc\u30c8\u5b9a\u7fa9\u306e\u914d\u5217\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u30eb\u30fc\u30c8\u5b9a\u7fa9\u306b\u306f\u3001\u6b21\u306e\u90e8\u5206\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30fb \u30d1\u30b9\uff1a \u30eb\u30fc\u30bf\u306f\u3001\u30d6\u30e9\u30a6\u30b6\u306e\u30a2\u30c9\u30ec\u30b9\u30d0\u30fc\uff08\u30d2\u30fc\u30ed\u30fc\uff09\u306eURL\u3078\u306e\u3053\u306e\u30eb\u30fc\u30c8\u306e\u30d1\u30b9\u3092\u7167\u5408\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\uff1a \u3053\u306e\u30eb\u30fc\u30c8\uff08<strong>HeroesComponent<\/strong>\uff09\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308b\u969b\u306b\u30eb\u30fc\u30bf\u304c\u4f5c\u6210\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3002<\/p>\n<p>&#8220;&#8220;&#8220;<br \/>\n\u300c<a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html\" target=\"_blank\">Routing\uff06Navigation\u300d\u30da\u30fc\u30b8<\/a>\u3067\u3001\u300cRoutes\u300d\u3067\u7d4c\u8def\u3092\u5b9a\u7fa9\u3059\u308b\u65b9\u6cd5\u306e\u8a73\u7d30\u3092\u8aad\u3093\u3067\u304f\u3060\u3055\u3044\u3002<br \/>\n&#8220;&#8220;&#8220;<\/p>\n<h5>Make the router available<\/h5>\n<p><strong>RouterModule<\/strong>\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3001<strong>AppModule imports<\/strong>\u914d\u5217\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app.module.ts (app routing)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import { NgModule }       from '@angular\/core';\r\nimport { BrowserModule }  from '@angular\/platform-browser';\r\nimport { FormsModule }    from '@angular\/forms';\r\nimport { RouterModule }   from '@angular\/router';\r\n\r\nimport { AppComponent }        from '.\/app.component';\r\nimport { HeroDetailComponent } from '.\/hero-detail.component';\r\nimport { HeroesComponent }     from '.\/heroes.component';\r\nimport { HeroService }         from '.\/hero.service';\r\n\r\n@NgModule({\r\n  imports: &#x5B;\r\n    BrowserModule,\r\n    FormsModule,\r\n    RouterModule.forRoot(&#x5B;\r\n      {\r\n        path: 'heroes',\r\n        component: HeroesComponent\r\n      }\r\n    ])\r\n  ],\r\n  declarations: &#x5B;\r\n    AppComponent,\r\n    HeroDetailComponent,\r\n    HeroesComponent\r\n  ],\r\n  providers: &#x5B;\r\n    HeroService\r\n  ],\r\n  bootstrap: &#x5B; AppComponent ]\r\n})\r\nexport class AppModule {\r\n}<\/pre>\n<p>&#8220;&#8220;&#8220;<br \/>\n\u8a2d\u5b9a\u3055\u308c\u305f\u30eb\u30fc\u30bf\u30fc\u304c\u3001\u30a2\u30d7\u30ea\u306e\u30eb\u30fc\u30c8\u306b\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001forRoot\uff08\uff09\u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3073\u51fa\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>forRoot\uff08\uff09\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u5fc5\u8981\u306a\u30eb\u30fc\u30bf\u30b5\u30fc\u30d3\u30b9\u30d7\u30ed\u30d0\u30a4\u30c0\u3068\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u3092\u63d0\u4f9b\u3057\u3001\u73fe\u5728\u306e\u30d6\u30e9\u30a6\u30b6\u306eURL\u306b\u57fa\u200b\u200b\u3065\u3044\u3066\u521d\u671f\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<br \/>\n&#8220;&#8220;&#8220;<\/p>\n<h5>Router outlet<\/h5>\n<p>\u30d1\u30b9\u306e\/ heroes\u3092URL\u306e\u6700\u5f8c\u306b\u3042\u308b\u30d6\u30e9\u30a6\u30b6\u306e\u30a2\u30c9\u30ec\u30b9\u30d0\u30fc\u306b\u8cbc\u308a\u4ed8\u3051\u308b\u3068\u3001\u30eb\u30fc\u30bf\u306f\u305d\u308c\u3092\u30d2\u30fc\u30ed\u30fc\u30eb\u30fc\u30c8\u306b\u4e00\u81f4\u3055\u305b\u3001<strong>HeroesComponent<\/strong>\u3092\u8868\u793a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001\u30eb\u30fc\u30bf\u306b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u8868\u793a\u5148\u3092\u4f1d\u3048\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3092\u884c\u3046\u306b\u306f\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u6700\u5f8c\u306b&lt;router-outlet&gt;\u8981\u7d20\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 <\/p>\n<p><strong>RouterOutlet<\/strong>\u306f\u3001<strong>RouterModule<\/strong>\u306b\u3088\u3063\u3066\u63d0\u4f9b\u3055\u308c\u308b\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u306e1\u3064\u3067\u3059\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u304c\u30a2\u30d7\u30ea\u3092\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308b\u3068\u3001\u30eb\u30fc\u30bf\u306f&lt;router-outlet&gt;\u306e\u3059\u3050\u4e0b\u306b\u3042\u308b\u5404\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<h5>Router links<\/h5>\n<p>\u30e6\u30fc\u30b6\u30fc\u306f\u3001\u30a2\u30c9\u30ec\u30b9\u30d0\u30fc\u306b\u30eb\u30fc\u30c8URL\u3092\u8cbc\u308a\u4ed8\u3051\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u4ee3\u308f\u308a\u306b\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u30a2\u30f3\u30ab\u30fc\u30bf\u30b0\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001<strong>HeroesComponent<\/strong>\u3078\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u304c\u30c8\u30ea\u30ac\u30fc\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u6539\u8a02\u3055\u308c\u305f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app.component.ts (template-v2)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">template: `\r\n   &lt;h1&gt;{{title}}&lt;\/h1&gt;\r\n   &lt;a routerLink=&quot;\/heroes&quot;&gt;Heroes&lt;\/a&gt;\r\n   &lt;router-outlet&gt;&lt;\/router-outlet&gt;\r\n `<\/pre>\n<p>\u30a2\u30f3\u30ab\u30fc\u30bf\u30b0\u5185\u306e<strong>routerLink<\/strong>\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>RouterLink<\/strong>\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\uff08\u5225\u306e<strong>RouterModule<\/strong>\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\uff09\u306f\u3001\u30e6\u30fc\u30b6\u304c\u30ea\u30f3\u30af\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u3068\u304d\u306b\u3069\u3053\u3092\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308b\u304b\u3092\u30eb\u30fc\u30bf\u306b\u901a\u77e5\u3059\u308b\u6587\u5b57\u5217\u306b\u30d0\u30a4\u30f3\u30c9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30ea\u30f3\u30af\u306f\u52d5\u7684\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u547d\u4ee4\u306f\u3001\u7d4c\u8def\u30d1\u30b9\u3078\u306e1\u56de\u306e\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3067\u5b9a\u7fa9\u3055\u308c\u308b\u3002<\/p>\n<p>\u30eb\u30fc\u30c8\u8a2d\u5b9a\u3092\u632f\u308a\u8fd4\u308b\u3068\u3001 &#8216;\/ heroes&#8217;\u304c\u3001<strong>HeroesComponent<\/strong>\u3078\u306e\u30eb\u30fc\u30c8\u306e\u30d1\u30b9\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30c0\u30a4\u30ca\u30df\u30c3\u30af\u30eb\u30fc\u30bf\u30ea\u30f3\u30af\u3068\u30ea\u30f3\u30af\u30d1\u30e9\u30e1\u30fc\u30bf\u914d\u5217\u306e\u8a73\u7d30\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html#\" target=\"_blank\">Routing\uff06Navigation<\/a>\u30da\u30fc\u30b8\u306e<a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html#link-parameters-array\" target=\"_blank\">Appendix\uff1aLink Parameters Array<\/a>\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30d6\u30e9\u30a6\u30b6\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d6\u30e9\u30a6\u30b6\u306b\u306f\u3001\u30a2\u30d7\u30ea\u306e\u30bf\u30a4\u30c8\u30eb\u3068\u30d2\u30fc\u30ed\u30fc\u306e\u30ea\u30f3\u30af\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u304c\u3001\u30d2\u30fc\u30ed\u30fc\u306e\u30ea\u30b9\u30c8\u306f\u8868\u793a\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<p><strong>src\/app\/app.component.ts (v2)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import { Component } from '@angular\/core';\r\n@Component({\r\n  selector: 'my-app',\r\n  template: `\r\n     &lt;h1&gt;{{title}}&lt;\/h1&gt;\r\n     &lt;a routerLink=&quot;\/heroes&quot;&gt;Heroes&lt;\/a&gt;\r\n     &lt;router-outlet&gt;&lt;\/router-outlet&gt;\r\n   `\r\n})\r\nexport class AppComponent {\r\n  title = 'Tour of Heroes';\r\n}<\/pre>\n<p><strong>AppComponent<\/strong>\u306f\u30eb\u30fc\u30bf\u30fc\u306b\u63a5\u7d9a\u3055\u308c\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3055\u308c\u305f\u30d3\u30e5\u30fc\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u305f\u3081\u3001\u3053\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30bf\u30a4\u30d7\u3092\u4ed6\u306e\u7a2e\u985e\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u533a\u5225\u3059\u308b\u305f\u3081\u306b\u3001\u3053\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30bf\u30a4\u30d7\u3092\u30eb\u30fc\u30bf\u30fc\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u547c\u3073\u307e\u3059\u3002<\/p>\n<h4>Add a dashboard<\/h4>\n<p>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306f\u3001\u8907\u6570\u306e\u30d3\u30e5\u30fc\u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u306b\u306e\u307f\u610f\u5473\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u5225\u306e\u30d3\u30e5\u30fc\u3092\u8ffd\u52a0\u3059\u308b\u306b\u306f\u3001\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0 <strong>DashboardComponent<\/strong>\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30ca\u30d3\u30b2\u30fc\u30c8\u3067\u304d\u308b\u5834\u6240\u3067\u3059\u3002<\/p>\n<p><strong>src\/app\/dashboard.component.ts (v1)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import { Component } from '@angular\/core';\r\n\r\n@Component({\r\n  selector: 'my-dashboard',\r\n  template: '&lt;h3&gt;My Dashboard&lt;\/h3&gt;'\r\n})\r\nexport class DashboardComponent { }\r\n<\/pre>\n<p>\u5f8c\u3067\u3053\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u3088\u308a\u4fbf\u5229\u306b\u3059\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<h5>Configure the dashboard route<\/h5>\n<p>\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308b\u3088\u3046\u306b\u3001<strong>app.module.ts<\/strong>\u3092\u6559\u3048\u308b\u306b\u306f\u3001\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3001\u6b21\u306e\u30eb\u30fc\u30c8\u5b9a\u7fa9\u3092\u30eb\u30fc\u30c8\u5b9a\u7fa9\u914d\u5217\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app.module.ts (Dashboard route)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">{\r\n  path: 'dashboard',\r\n  component: DashboardComponent\r\n},<\/pre>\n<p>\u307e\u305f\u3001<strong>DashboardComponent<\/strong>\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066<strong>AppModule<\/strong>\u306e\u5ba3\u8a00\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app.module.ts (dashboard)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">declarations: &#x5B;\r\n  AppComponent,\r\n  DashboardComponent,\r\n  HeroDetailComponent,\r\n  HeroesComponent\r\n],<\/pre>\n<h5>Add a redirect route<\/h5>\n<p>\u30a2\u30d7\u30ea\u304c\u8d77\u52d5\u3059\u308b\u3068\u3001\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u304c\u8868\u793a\u3055\u308c\u3001\u30d6\u30e9\u30a6\u30b6\u306e\u30a2\u30c9\u30ec\u30b9\u30d0\u30fc\u306b\/\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306eURL\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u73fe\u5728\u3001\u30d6\u30e9\u30a6\u30b6\u306f\u30a2\u30c9\u30ec\u30b9\u30d0\u30fc\u306b\/\u3067\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3092\u5b9f\u73fe\u3059\u308b\u306b\u306f\u3001\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u30eb\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u30eb\u30fc\u30c8\u5b9a\u7fa9\u306e\u914d\u5217\u306b\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app.module.ts (redirect)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">{\r\n  path: '',\r\n  redirectTo: '\/dashboard',\r\n  pathMatch: 'full'\r\n},<\/pre>\n<p>&#8220;&#8220;&#8220;<br \/>\n<a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html#\" target=\"_blank\"> Routing &#038; Navigation<\/a> \u30da\u30fc\u30b8\u306e <a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html#!#redirect\" target=\"_blank\">Redirecting routes<\/a> \u30bb\u30af\u30b7\u30e7\u30f3\u3067\u3001\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u306e\u8a73\u7d30\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<br \/>\n&#8220;&#8220;&#8220;<\/p>\n<h5>Add navigation to the template<\/h5>\n<p>\u30d2\u30fc\u30ed\u30fc\u30ba\u30ea\u30f3\u30af\u306e\u3059\u3050\u4e0a\u306b\u3042\u308b\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3078\u306e\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30ea\u30f3\u30af\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app.component.ts (template-v3)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">template: `\r\n   &lt;h1&gt;{{title}}&lt;\/h1&gt;\r\n   &lt;nav&gt;\r\n     &lt;a routerLink=&quot;\/dashboard&quot;&gt;Dashboard&lt;\/a&gt;\r\n     &lt;a routerLink=&quot;\/heroes&quot;&gt;Heroes&lt;\/a&gt;\r\n   &lt;\/nav&gt;\r\n   &lt;router-outlet&gt;&lt;\/router-outlet&gt;\r\n `<\/pre>\n<p>&#8220;&#8220;&#8220;<br \/>\n&lt;nav&gt;\u30bf\u30b0\u306f\u307e\u3060\u4f55\u3082\u3057\u307e\u305b\u3093\u304c\u3001\u5f8c\u3067\u30ea\u30f3\u30af\u3092\u30b9\u30bf\u30a4\u30eb\u3059\u308b\u3068\u304d\u306b\u4fbf\u5229\u3067\u3059\u3002<br \/>\n&#8220;&#8220;&#8220;<\/p>\n<p>\u30d6\u30e9\u30a6\u30b6\u3067\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30eb\u30fc\u30c8\uff08\/\uff09\u306b\u79fb\u52d5\u3057\u3066\u30ea\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<\/p>\n<p>\u30a2\u30d7\u30ea\u306f\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u3092\u8868\u793a\u3057\u3001\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u3068\u30d2\u30fc\u30ed\u30fc\u306e\u9593\u3092\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h4>Add heroes to the dashboard<\/h4>\n<p>\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u3092\u3082\u3063\u3068\u9762\u767d\u304f\u3059\u308b\u305f\u3081\u306b\u3001\u4e0a\u4f4d4\u4eba\u306e\u30d2\u30fc\u30ed\u30fc\u3092\u4e00\u76ee\u3067\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30e1\u30bf\u30c7\u30fc\u30bf\u3092\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u3059templateUrl\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/dashboard.component.ts (metadata)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">@Component({\r\n  selector: 'my-dashboard',\r\n  templateUrl: '.\/dashboard.component.html',\r\n})<\/pre>\n<p>\u3053\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u542b\u3080\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/dashboard.component.html<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;h3&gt;Top Heroes&lt;\/h3&gt;\r\n&lt;div class=&quot;grid grid-pad&quot;&gt;\r\n  &lt;div *ngFor=&quot;let hero of heroes&quot; class=&quot;col-1-4&quot;&gt;\r\n    &lt;div class=&quot;module hero&quot;&gt;\r\n      &lt;h4&gt;{{hero.name}}&lt;\/h4&gt;\r\n    &lt;\/div&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>* ngFor\u306f\u518d\u3073\u30d2\u30fc\u30ed\u30fc\u306e\u30ea\u30b9\u30c8\u3092\u53cd\u5fa9\u3057\u3066\u305d\u306e\u540d\u524d\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u4f59\u5206\u306a&lt;div&gt;\u8981\u7d20\u306f\u5f8c\u3067\u30b9\u30bf\u30a4\u30ea\u30f3\u30b0\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>\n<h5>Sharing the HeroService<\/h5>\n<p>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u30d2\u30fc\u30ed\u30fc\u914d\u5217\u3092\u8aad\u307f\u8fbc\u3080\u306b\u306f\u3001<strong>HeroService<\/strong>\u3092\u518d\u5229\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u524d\u306f\u3001<strong>HeroService<\/strong>\u3092<strong>HeroesComponent<\/strong>\u306e\u30d7\u30ed\u30d0\u30a4\u30c0\u914d\u5217\u304b\u3089\u524a\u9664\u3057\u3001\u305d\u308c\u3092<strong>AppModule<\/strong>\u306e\u30d7\u30ed\u30d0\u30a4\u30c0\u914d\u5217\u306b\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u52d5\u304d\u306b\u3088\u308a\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u3059\u3079\u3066\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u4f7f\u7528\u53ef\u80fd\u306a\u3001\u30b7\u30f3\u30b0\u30eb\u30c8\u30f3\u306e<strong>HeroService<\/strong>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u4f5c\u6210\u3055\u308c\u307e\u3057\u305f\u3002 <\/p>\n<p>Angular\u306f<strong>HeroService<\/strong>\u3092\u6ce8\u5165\u3057\u3001<strong>DashboardComponent<\/strong>\u3067\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h5>Get heroes<\/h5>\n<p><strong>dashboard.component.ts<\/strong>\u306b\u3001\u6b21\u306eimport\u6587\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/dashboard.component.ts (imports)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import { Component, OnInit } from '@angular\/core';\r\n\r\nimport { Hero } from '.\/hero';\r\nimport { HeroService } from '.\/hero.service';<\/pre>\n<p>\u6b21\u306e\u3088\u3046\u306b\u3001<strong>DashboardComponent<\/strong>\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/dashboard.component.ts (class)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">export class DashboardComponent implements OnInit {\r\n\r\n  heroes: Hero&#x5B;] = &#x5B;];\r\n\r\n  constructor(private heroService: HeroService) { }\r\n\r\n  ngOnInit(): void {\r\n    this.heroService.getHeroes()\r\n      .then(heroes =&gt; this.heroes = heroes.slice(1, 5));\r\n  }\r\n}<\/pre>\n<p>\u3053\u306e\u7a2e\u306e\u30ed\u30b8\u30c3\u30af\u306f\u3001<strong>HeroesComponent<\/strong>\u3067\u3082\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30fb \u30d2\u30fc\u30ed\u30fc\u914d\u5217\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306b<strong>HeroService<\/strong>\u3092\u633f\u5165\u3057\u3001\u305d\u308c\u3092\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u306a<strong>heroService<\/strong>\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u4fdd\u6301\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u30b5\u30fc\u30d3\u30b9\u3092\u547c\u3073\u51fa\u3057\u3066\u3001<strong>Angular ngOnInit<\/strong>\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u30d5\u30c3\u30af\u306e\u4e2d\u306e\u30d2\u30fc\u30ed\u30fc\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u3067\u306f\u3001Array.slice\u30e1\u30bd\u30c3\u30c9\u30674\u3064\u306e\u30d2\u30fc\u30ed\u30fc\uff082\u4f4d\u30013\u4f4d\u30014\u4f4d\u30015\u4f4d\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d6\u30e9\u30a6\u30b6\u3092\u66f4\u65b0\u3057\u3066\u3001\u65b0\u3057\u3044\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306b4\u3064\u306e\u30d2\u30fc\u30ed\u30fc\u540d\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<h4>Navigating to hero details<\/h4>\n<p>\u9078\u629e\u3055\u308c\u305f\u30d2\u30fc\u30ed\u30fc\u306e\u8a73\u7d30\u304c\u3001<strong>HeroesComponent<\/strong>\u306e\u4e0b\u90e8\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u304c\u3001\u30e6\u30fc\u30b6\u30fc\u306f\u6b21\u306e\u8ffd\u52a0\u306e\u65b9\u6cd5\u3067<strong>HeroDetailComponent<\/strong>\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30fb \u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u304b\u3089\u9078\u629e\u3055\u308c\u305f\u30d2\u30fc\u30ed\u30fc\u307e\u3067\u3002<\/p>\n<p>\u30fb \u30d2\u30fc\u30ed\u30fc\u30ea\u30b9\u30c8\u304b\u3089\u9078\u3070\u308c\u305f\u30d2\u30fc\u30ed\u30fc\u307e\u3067\u3002<\/p>\n<p>\u30fb \u30d6\u30e9\u30a6\u30b6\u306e\u30a2\u30c9\u30ec\u30b9\u30d0\u30fc\u306b\u8cbc\u308a\u4ed8\u3051\u3089\u308c\u305f&#8221;deep link&#8221;URL\u304b\u3089\u3002<\/p>\n<h5>Routing to a hero detail<\/h5>\n<p><strong>app.module.ts<\/strong>\u5185\u306e <strong>HeroDetailComponent<\/strong>\u3078\u306e\u30eb\u30fc\u30c8\u3092\u8ffd\u52a0\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ed6\u306e\u30eb\u30fc\u30c8\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>HeroDetailComponent<\/strong>\u306b\u3001\u3069\u306e\u30d2\u30fc\u30ed\u30fc\u3092\u8868\u793a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u304b\u3068\u3044\u3046\u70b9\u3067\u3001\u65b0\u3057\u3044\u30eb\u30fc\u30c8\u306f\u73cd\u3057\u3044\u3067\u3059\u3002<\/p>\n<p>\u3042\u306a\u305f\u306f\u3001<strong>HeroesComponent<\/strong>\u307e\u305f\u306f\u3001<strong>DashboardComponent<\/strong>\u306b\u4f55\u3082\u8a00\u308f\u305b\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p>\u73fe\u5728\u3001\u89aa\u306e<strong>HeroesComponent<\/strong>\u306f\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306ehero\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6b21\u306e\u3088\u3046\u306a\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3092\u6301\u3064hero\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;hero-detail &#x5B;hero]=&quot;selectedHero&quot;&gt;&lt;\/hero-detail&gt;<\/pre>\n<p>\u3057\u304b\u3057\u3001\u3053\u306e\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306f\u3069\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30b7\u30ca\u30ea\u30aa\u3067\u3082\u6a5f\u80fd\u3057\u307e\u305b\u3093\u3002<\/p>\n<h5>Parameterized route<\/h5>\n<p>\u30d2\u30fc\u30ed\u30fc\u306eID\u3092URL\u306b\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 id\u304c11\u306e\u30d2\u30fc\u30ed\u30fc\u306b\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3059\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306aURL\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\/detail\/11<\/pre>\n<p>URL\u306e\/ detail \/\u90e8\u5206\u306f\u5b9a\u6570\u3067\u3059\u3002\u672b\u5c3e\u306e\u6570\u5024\u306f\u82f1\u96c4\u304b\u3089\u82f1\u96c4\u306b\u5909\u308f\u308a\u307e\u3059\u3002<\/p>\n<p>\u30d2\u30fc\u30ed\u30fc\u306eID\u3092\u8868\u3059\u30d1\u30e9\u30e1\u30fc\u30bf\uff08\u307e\u305f\u306f\u30c8\u30fc\u30af\u30f3\uff09\u3092\u4f7f\u7528\u3057\u3066\u3001\u30eb\u30fc\u30c8\u306e\u53ef\u5909\u90e8\u5206\u3092\u8868\u73fe\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h5>Configure a route with a parameter<\/h5>\n<p>\u6b21\u306e\u30eb\u30fc\u30c8\u5b9a\u7fa9\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app.module.ts (hero detail)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">{\r\n  path: 'detail\/:id',\r\n  component: HeroDetailComponent\r\n},<\/pre>\n<p>\u30d1\u30b9\u306e\u30b3\u30ed\u30f3\uff08:)\u306f\u3001\u6b21\u306e\u3053\u3068\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>id\u306f\u3001<strong>HeroDetailComponent<\/strong>\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308b\u3068\u304d\u306b\u3001\u7279\u5b9a\u306e\u30d2\u30fc\u30ed\u30fcID\u306e\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\u3067\u3059\u3002<\/p>\n<p>\u3042\u306a\u305f\u306f\u30a2\u30d7\u30ea\u306e\u30eb\u30fc\u30c8\u3092\u7d42\u3048\u307e\u3057\u305f\u3002<\/p>\n<p>\u7279\u5b9a\u306e\u30d2\u30fc\u30ed\u30fc\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306b\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30ea\u30f3\u30af\u3092\u30af\u30ea\u30c3\u30af\u3057\u306a\u3044\u305f\u3081\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b&#8217;Hero Detail&#8217;\u30ea\u30f3\u30af\u3092\u8ffd\u52a0\u3057\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p>\u540d\u524d\u304c\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306b\u8868\u793a\u3055\u308c\u308b\u304b\u82f1\u96c4\u30ea\u30b9\u30c8\u306b\u8868\u793a\u3055\u308c\u308b\u304b\u306b\u304b\u304b\u308f\u3089\u305a\u3001\u30d2\u30fc\u30ed\u30fc\u540d\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><strong>HeroDetailComponent<\/strong>\u304c\u6539\u8a02\u3055\u308c\u3001\u30ca\u30d3\u30b2\u30fc\u30c8\u3067\u304d\u308b\u72b6\u614b\u306b\u306a\u308b\u307e\u3067\u3001\u30d2\u30fc\u30ed\u30fc\u306e\u30af\u30ea\u30c3\u30af\u3092\u8ffd\u52a0\u3059\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<h4>Revise the HeroDetailComponent<\/h4>\n<p><strong>HeroDetailComponent<\/strong>\u306e\u5b9f\u88c5\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<p><strong>src\/app\/hero-detail.component.ts (current)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import { Component, Input } from '@angular\/core';\r\nimport { Hero } from '.\/hero';\r\n@Component({\r\n  selector: 'hero-detail',\r\n  template: `\r\n    &lt;div *ngIf=&quot;hero&quot;&gt;\r\n      &lt;h2&gt;{{hero.name}} details!&lt;\/h2&gt;\r\n      &lt;div&gt;\r\n        &lt;label&gt;id: &lt;\/label&gt;{{hero.id}}\r\n      &lt;\/div&gt;\r\n      &lt;div&gt;\r\n        &lt;label&gt;name: &lt;\/label&gt;\r\n        &lt;input &#x5B;(ngModel)]=&quot;hero.name&quot; placeholder=&quot;name&quot;\/&gt;\r\n      &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n  `\r\n})\r\nexport class HeroDetailComponent {\r\n  @Input() hero: Hero;\r\n}<\/pre>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u5909\u66f4\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u30d2\u30fc\u30ed\u30fc\u306e\u540d\u524d\u3082\u540c\u3058\u3088\u3046\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u5927\u304d\u306a\u5909\u5316\u306f\u3001\u3042\u306a\u305f\u304c\u82f1\u96c4\u306e\u540d\u524d\u3092\u5f97\u308b\u65b9\u6cd5\u306b\u3088\u3063\u3066\u5f15\u304d\u8d77\u3053\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3042\u306a\u305f\u306f\u3082\u306f\u3084\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3067\u4e3b\u4eba\u516c\u3092\u53d7\u3051\u53d6\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u65b0\u3057\u3044<strong>HeroDetailComponent<\/strong>\u306f\u3001<strong>ActivatedRoute<\/strong>\u30b5\u30fc\u30d3\u30b9\u306e<strong>Observable<\/strong>\u30d1\u30e9\u30e1\u30fc\u30bf\u304b\u3089id\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3001<strong>HeroService<\/strong>\u3092\u4f7f\u7528\u3057\u3066\u305d\u306eID\u3092\u6301\u3064\u30d2\u30fc\u30ed\u30fc\u3092\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306e\u30a4\u30f3\u30dd\u30fc\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/hero-detail.component (added-imports)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\/\/ Keep the Input import for now, you'll remove it later:\r\nimport { Component, Input, OnInit } from '@angular\/core';\r\nimport { ActivatedRoute, Params }   from '@angular\/router';\r\nimport { Location }                 from '@angular\/common';\r\n\r\nimport { HeroService } from '.\/hero.service';<\/pre>\n<p>ActivatedRoute\u3001HeroService\u3001\u304a\u3088\u3073Location\u30b5\u30fc\u30d3\u30b9\u3092\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306b\u633f\u5165\u3057\u3001\u305d\u306e\u5024\u3092\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/hero-detail.component.ts (constructor)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">constructor(\r\n  private heroService: HeroService,\r\n  private route: ActivatedRoute,\r\n  private location: Location\r\n) {}<\/pre>\n<p>\u5f8c\u3067\u7d4c\u8def\u30d1\u30e9\u30e1\u30fc\u30bf<strong>Observable<\/strong>\u3067\u3001\u4f7f\u7528\u3059\u308b<strong>switchMap<\/strong>\u6f14\u7b97\u5b50\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/hero-detail.component.ts (switchMap import)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import 'rxjs\/add\/operator\/switchMap';<\/pre>\n<p>\u30af\u30e9\u30b9\u306bOnInit\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u5b9f\u88c5\u3059\u308b\u3088\u3046\u306b\u6307\u793a\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/hero-detail.component.ts (implement)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">export class HeroDetailComponent implements OnInit {<\/pre>\n<p>ngOnInit\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u30d5\u30c3\u30af\u306e\u4e2d\u3067\u3001<strong>Observable<\/strong>\u3068\u3044\u3046\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u3001<strong>ActivatedRoute<\/strong>\u30b5\u30fc\u30d3\u30b9\u304b\u3089id\u30d1\u30e9\u30e1\u30fc\u30bf\u5024\u3092\u62bd\u51fa\u3057\u3001HeroService\u3092\u4f7f\u7528\u3057\u3066\u305d\u306eID\u3092\u6301\u3064\u30d2\u30fc\u30ed\u30fc\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/hero-detail.component.ts (ngOnInit)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">ngOnInit(): void {\r\n  this.route.params\r\n    .switchMap((params: Params) =&gt; this.heroService.getHero(+params&#x5B;'id']))\r\n    .subscribe(hero =&gt; this.hero = hero);\r\n}<\/pre>\n<p><strong>switchMap<\/strong>\u30aa\u30da\u30ec\u30fc\u30bf\u306f\u3001<strong>Observable<\/strong>\u30eb\u30fc\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\u306eID\u3092<strong>HeroService.getHero\uff08\uff09<\/strong>\u30e1\u30bd\u30c3\u30c9\u306e\u7d50\u679c\u3067\u3042\u308b\u65b0\u3057\u3044<strong>Observable<\/strong>\u306b\u30de\u30c3\u30d7\u3057\u307e\u3059\u3002<\/p>\n<p>getHero\u8981\u6c42\u304c\u51e6\u7406\u3055\u308c\u3066\u3044\u308b\u9593\u306b\u30e6\u30fc\u30b6\u30fc\u304c\u3053\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u518d\u5ea6\u79fb\u52d5\u3057\u305f\u5834\u5408\u3001switchMap\u306f\u53e4\u3044\u8981\u6c42\u3092\u53d6\u308a\u6d88\u3057\u3001<strong>HeroService.getHero\uff08\uff09<\/strong>\u3092\u518d\u5ea6\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d2\u30fc\u30ed\u30fcid\u306f\u6570\u5b57\u3067\u3059\u3002<\/p>\n<p>\u30eb\u30fc\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u5e38\u306b\u6587\u5b57\u5217\u3067\u3059\u3002<\/p>\n<p>\u3057\u305f\u304c\u3063\u3066\u3001\u30eb\u30fc\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u5024\u306f\u3001JavaScript\uff08+\uff09\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3057\u3066\u6570\u5024\u306b\u5909\u63db\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>&#8220;&#8220;&#8220;<br \/>\n\u9000\u4f1a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304b\uff1f<\/p>\n<p> <a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html\" target=\"_blank\">Routing &#038; Navigation<\/a> \u30da\u30fc\u30b8\u306ethe <a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html#activated-route\" target=\"_blank\">one-stop-shop for route information<\/a> \u30bb\u30af\u30b7\u30e7\u30f3\u306b\u3042\u308bActivatedRoute\u3067\u8aac\u660e\u3057\u305f\u3088\u3046\u306b\u3001\u30eb\u30fc\u30bf\u30fc\u306f\u63d0\u4f9b\u3059\u308b\u30aa\u30d6\u30b6\u30fc\u30d0\u30d6\u30eb\u3092\u7ba1\u7406\u3057\u3001\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u3092\u30ed\u30fc\u30ab\u30e9\u30a4\u30ba\u3057\u307e\u3059\u3002<\/p>\n<p>\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u306f\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u7834\u68c4\u3055\u308c\u305f\u3068\u304d\u306b\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u3055\u308c\u3001\u30e1\u30e2\u30ea\u30fc\u30ea\u30fc\u30af\u3092\u9632\u304e\u307e\u3059\u3002<\/p>\n<p>\u3057\u305f\u304c\u3063\u3066\u3001Observable\u3068\u3044\u3046\u30d1\u30e9\u30e1\u30fc\u30bf\u30fcparams\u304b\u3089\u306e\u767b\u9332\u3092\u89e3\u9664\u3059\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n&#8220;&#8220;&#8220;<\/p>\n<h5>Add HeroService.getHero<\/h5>\n<p>\u524d\u306e\u30b3\u30fc\u30c9\u30b9\u30cb\u30da\u30c3\u30c8\u3067\u306f\u3001<strong>HeroService<\/strong>\u306b\u306fgetHero\uff08\uff09\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3053\u306e\u554f\u984c\u3092\u89e3\u6c7a\u3059\u308b\u306b\u306f\u3001<strong>HeroService<\/strong>\u3092\u958b\u304d\u3001<strong>getHeroes<\/strong>\u306e\u30d2\u30fc\u30ed\u30fc\u30ea\u30b9\u30c8\u3092id\u3067\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3059\u308bgetHero\uff08\uff09\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/hero.service.ts (getHero)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">getHero(id: number): Promise&lt;Hero&gt; {\r\n  return this.getHeroes()\r\n             .then(heroes =&gt; heroes.find(hero =&gt; hero.id === id));\r\n}<\/pre>\n<h5>Find the way back<\/h5>\n<p>\u30e6\u30fc\u30b6\u30fc\u306f\u3001<strong>HeroDetailComponent<\/strong>\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308b\u3044\u304f\u3064\u304b\u306e\u65b9\u6cd5\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5225\u306e\u5834\u6240\u306b\u79fb\u52d5\u3059\u308b\u306b\u306f\u3001<strong>AppComponent<\/strong>\u306e2\u3064\u306e\u30ea\u30f3\u30af\u306e\u3044\u305a\u308c\u304b\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u304b\u3001\u30d6\u30e9\u30a6\u30b6\u306e\u623b\u308b\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p>\u4eca\u5ea6\u306f\u3001\u4ee5\u524d\u306b\u633f\u5165\u3057\u305fLocation\u30b5\u30fc\u30d3\u30b9\u3092\u4f7f\u7528\u3057\u3066\u3001\u30d6\u30e9\u30a6\u30b6\u306e\u30d2\u30b9\u30c8\u30ea\u30b9\u30bf\u30c3\u30af\u306e1\u30b9\u30c6\u30c3\u30d7\u524d\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308bgoBack\uff08\uff09\u30e1\u30bd\u30c3\u30c9\u3068\u3044\u30463\u3064\u76ee\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/hero-detail.component.ts (goBack)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">goBack(): void {\r\n  this.location.back();\r\n}<\/pre>\n<p>\u3042\u307e\u308a\u306b\u3082\u9060\u304f\u306b\u623b\u308b\u3068\u3001\u30e6\u30fc\u30b6\u30fc\u306f\u30a2\u30d7\u30ea\u304b\u3089\u51fa\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>&#8220;&#8220;&#8220;<br \/>\n\u5b9f\u969b\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u306e\u554f\u984c\u3092CanDeactivate\u30ac\u30fc\u30c9\u3067\u9632\u3050\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 <a href=\"https:\/\/angular.io\/docs\/ts\/latest\/api\/router\/index\/CanDeactivate-interface.html\" target=\"_blank\">CanDeactivate\u30da\u30fc\u30b8<\/a>\u3067\u8a73\u3057\u304f\u8aad\u3080\u3002<br \/>\n&#8220;&#8220;&#8220;<\/p>\n<p>\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u8ffd\u52a0\u3059\u308b\u300c\u623b\u308b\u300d\u30dc\u30bf\u30f3\u306b\u30d0\u30a4\u30f3\u30c9\u3055\u308c\u305f\u30a4\u30d9\u30f3\u30c8\u3067\u7d50\u3070\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;button (click)=&quot;goBack()&quot;&gt;Back&lt;\/button&gt;<\/pre>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u3001<strong>hero-detail.component.html<\/strong>\u3068\u3044\u3046\u72ec\u81ea\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u79fb\u884c\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/hero-detail.component.html<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;div *ngIf=&quot;hero&quot;&gt;\r\n  &lt;h2&gt;{{hero.name}} details!&lt;\/h2&gt;\r\n  &lt;div&gt;\r\n    &lt;label&gt;id: &lt;\/label&gt;{{hero.id}}&lt;\/div&gt;\r\n  &lt;div&gt;\r\n    &lt;label&gt;name: &lt;\/label&gt;\r\n    &lt;input &#x5B;(ngModel)]=&quot;hero.name&quot; placeholder=&quot;name&quot; \/&gt;\r\n  &lt;\/div&gt;\r\n  &lt;button (click)=&quot;goBack()&quot;&gt;Back&lt;\/button&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u30e1\u30bf\u30c7\u30fc\u30bf\u3092\u3001\u4f5c\u6210\u3057\u305f\u3070\u304b\u308a\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u3059<strong>templateUrl<\/strong>\u3067\u66f4\u65b0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/hero-detail.component.ts (metadata)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">@Component({\r\n  selector: 'hero-detail',\r\n  templateUrl: '.\/hero-detail.component.html',\r\n})<\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u3092\u66f4\u65b0\u3057\u3066\u7d50\u679c\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h4>Select a dashboard hero<\/h4>\n<p>\u30e6\u30fc\u30b6\u30fc\u304c\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u3067\u30d2\u30fc\u30ed\u30fc\u3092\u9078\u629e\u3059\u308b\u3068\u3001\u30a2\u30d7\u30ea\u306f<strong>HeroDetailComponent<\/strong>\u306b\u79fb\u52d5\u3057\u3066\u3001\u9078\u629e\u3057\u305f\u30d2\u30fc\u30ed\u30fc\u3092\u8868\u793a\u304a\u3088\u3073\u7de8\u96c6\u3057\u307e\u3059\u3002<\/p>\n<p>\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u30d2\u30fc\u30ed\u30fc\u306f\u30dc\u30bf\u30f3\u306e\u3088\u3046\u306a\u30d6\u30ed\u30c3\u30af\u3068\u3057\u3066\u8868\u793a\u3055\u308c\u307e\u3059\u304c\u3001\u30a2\u30f3\u30ab\u30fc\u30bf\u30b0\u306e\u3088\u3046\u306b\u52d5\u4f5c\u3059\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<p>\u30d2\u30fc\u30ed\u30fc\u30d6\u30ed\u30c3\u30af\u306b\u30ab\u30fc\u30bd\u30eb\u3092\u5408\u308f\u305b\u308b\u3068\u3001\u30bf\u30fc\u30b2\u30c3\u30c8URL\u304c\u30d6\u30e9\u30a6\u30b6\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u306b\u8868\u793a\u3055\u308c\u3001\u30e6\u30fc\u30b6\u30fc\u306f\u30ea\u30f3\u30af\u3092\u30b3\u30d4\u30fc\u3059\u308b\u304b\u3001\u65b0\u3057\u3044\u30bf\u30d6\u3067\u30d2\u30fc\u30ed\u30fc\u306e\u8a73\u7d30\u30d3\u30e5\u30fc\u3092\u958b\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u52b9\u679c\u3092\u5f97\u308b\u306b\u306f\u3001<strong>dashboard.component.html<\/strong>\u3092\u518d\u5ea6\u958b\u304d\u3001\u7e70\u308a\u8fd4\u3057&lt;div * ngFor &#8230;&gt;\u30bf\u30b0\u3092&lt;a&gt;\u30bf\u30b0\u306b\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<p>\u958b\u59cb&lt;a&gt;\u30bf\u30b0\u3092\u6b21\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/dashboard.component.html (repeated &lt;a&gt; tag)<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;a *ngFor=&quot;let hero of heroes&quot;  &#x5B;routerLink]=&quot;&#x5B;'\/detail', hero.id]&quot;  class=&quot;col-1-4&quot;&gt;<\/pre>\n<p>[routerLink]\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306b\u6ce8\u76ee\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3053\u306e\u30da\u30fc\u30b8\u306e Router links\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u8aac\u660e\u3057\u305f\u3088\u3046\u306b\u3001<strong>AppComponent<\/strong>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u6700\u4e0a\u4f4d\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001\u5b9b\u5148\u30ea\u30f3\u30af\u306e\u56fa\u5b9a\u30d1\u30b9&#8221;\/dashboard&#8221;\u3068&#8221;\/heroes&#8221;\u306b\u8a2d\u5b9a\u3055\u308c\u305f\u30eb\u30fc\u30bf\u30ea\u30f3\u30af\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001\u30ea\u30f3\u30af\u30d1\u30e9\u30e1\u30fc\u30bf\u914d\u5217\u3092\u542b\u3080\u5f0f\u306b\u30d0\u30a4\u30f3\u30c9\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u914d\u5217\u306b\u306f\u3001\u76ee\u7684\u5730\u30eb\u30fc\u30c8\u306e\u30d1\u30b9\u3068\u73fe\u5728\u306e\u30d2\u30fc\u30ed\u30fc\u306eID\u306e\u5024\u306b\u8a2d\u5b9a\u3055\u308c\u305f\u30eb\u30fc\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\u306e2\u3064\u306e\u8981\u7d20\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>2\u3064\u306e\u914d\u5217\u9805\u76ee\u306f\u3001\u524d\u306bapp.module.ts\u306b\u8ffd\u52a0\u3057\u305f\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u3055\u308c\u305f\u30d2\u30fc\u30ed\u30fc\u8a73\u7d30\u30eb\u30fc\u30c8\u5b9a\u7fa9\u306epath\u3068\uff1aid\u30c8\u30fc\u30af\u30f3\u306b\u63c3\u3048\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app.module.ts (hero detail)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">{\r\n  path: 'detail\/:id',\r\n  component: HeroDetailComponent\r\n},<\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u3092\u66f4\u65b0\u3057\u3001\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u304b\u3089\u30d2\u30fc\u30ed\u30fc\u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n<p>\u30a2\u30d7\u30ea\u306f\u305d\u306e\u30d2\u30fc\u30ed\u30fc\u306e\u8a73\u7d30\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3057\u307e\u3059\u3002<\/p>\n<h4>Refactor routes to a Routing Module<\/h4>\n<p>\u7d0420\u884c\u306eAppModule\u304c4\u3064\u306e\u30eb\u30fc\u30c8\u3092\u69cb\u6210\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u307b\u3068\u3093\u3069\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u306f\u3055\u3089\u306b\u591a\u304f\u306e\u30eb\u30fc\u30c8\u304c\u3042\u308a\u3001\u4e0d\u8981\u306a\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u3084\u4e0d\u6b63\u306a\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u4fdd\u8b77\u3059\u308b\u305f\u3081\u306e\u30ac\u30fc\u30c9\u30b5\u30fc\u30d3\u30b9\u304c\u8ffd\u52a0\u3055\u308c\u3066\u3044\u307e\u3059\u3002 \uff08<a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html\" target=\"_blank\">Routing\uff06Navigation\u30da\u30fc\u30b8<\/a>\u306e<a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html#guards\" target=\"_blank\">Route Guards<\/a>\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002\uff09\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u8003\u616e\u4e8b\u9805\u306f\u3001\u3053\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u3059\u3050\u306b\u652f\u914d\u3057\u3001Angular\u30b3\u30f3\u30d1\u30a4\u30e9\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5168\u4f53\u306b\u95a2\u3059\u308b\u91cd\u8981\u306a\u4e8b\u5b9f\u3092\u78ba\u7acb\u3059\u308b\u3053\u3068\u3092\u4e3b\u76ee\u7684\u3068\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u8a2d\u5b9a\u3092\u72ec\u81ea\u306e\u30af\u30e9\u30b9\u306b\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u3059\u308b\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\u3002<\/p>\n<p>\u73fe\u5728\u306e<strong>RouterModule.forRoot\uff08\uff09<\/strong>\u306f\u3001<strong>Angular ModuleWithProviders<\/strong>\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u5c02\u7528\u306e\u30af\u30e9\u30b9\u306f\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u8a73\u7d30\u306f\u3001<a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html\" target=\"_blank\">Routing\uff06Navigation\u30da\u30fc\u30b8<\/a>\u306e<a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/router.html#routing-module\" target=\"_blank\">Milestone\uff032\uff1aRouting Module\u30bb\u30af\u30b7\u30e7\u30f3<\/a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u898f\u5247\u306b\u3088\u3063\u3066\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30e2\u30b8\u30e5\u30fc\u30eb\u540d\u306b\u306f\u300c\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u300d\u3068\u3044\u3046\u5358\u8a9e\u304c\u542b\u307e\u308c\u3001\u30ca\u30d3\u30b2\u30fc\u30c8\u3055\u308c\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u5ba3\u8a00\u3059\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u540d\u524d\u3068\u63c3\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n<p><strong>app-routing.module.ts<\/strong>\u30d5\u30a1\u30a4\u30eb\u3092\u3001<strong>app.module.ts<\/strong>\u306e\u5144\u5f1f\u3068\u3057\u3066\u4f5c\u6210\u3057\u307e\u3059\u3002 <\/p>\n<p>AppModule\u30af\u30e9\u30b9\u304b\u3089\u62bd\u51fa\u3057\u305f\u6b21\u306e\u5185\u5bb9\u3092\u4e0e\u3048\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app-routing.module.ts<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import { NgModule }             from '@angular\/core';\r\nimport { RouterModule, Routes } from '@angular\/router';\r\nimport { DashboardComponent }   from '.\/dashboard.component';\r\nimport { HeroesComponent }      from '.\/heroes.component';\r\nimport { HeroDetailComponent }  from '.\/hero-detail.component';\r\nconst routes: Routes = &#x5B;\r\n  { path: '', redirectTo: '\/dashboard', pathMatch: 'full' },\r\n  { path: 'dashboard',  component: DashboardComponent },\r\n  { path: 'detail\/:id', component: HeroDetailComponent },\r\n  { path: 'heroes',     component: HeroesComponent }\r\n];\r\n@NgModule({\r\n  imports: &#x5B; RouterModule.forRoot(routes) ],\r\n  exports: &#x5B; RouterModule ]\r\n})\r\nexport class AppRoutingModule {}<\/pre>\n<p>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5178\u578b\u7684\u306a\u4f8b\u3092\u6b21\u306b\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u3001\u30eb\u30fc\u30c8\u3092\u5909\u6570\u306b\u30d7\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u3053\u306e\u5909\u6570\u306f\u3001\u5c06\u6765\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3059\u308b\u5834\u5408\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30e2\u30b8\u30e5\u30fc\u30eb\u30d1\u30bf\u30fc\u30f3\u3092\u660e\u78ba\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u3001\u30a4\u30f3\u30dd\u30fc\u30c8\u306b<strong>RouterModule.forRoot<\/strong>\uff08\u30eb\u30fc\u30c8\uff09\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u3001<strong>RouterModule<\/strong>\u3092\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u306b\u8ffd\u52a0\u3057\u3066\u3001\u30b3\u30f3\u30d1\u30cb\u30aa\u30f3\u30e2\u30b8\u30e5\u30fc\u30eb\u5185\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c<strong>RouterLink<\/strong>\u3084<\/p>\n<p>\u30fb <strong>RouterOutlet<\/strong>\u306a\u3069\u306e\u30eb\u30fc\u30bf\u5ba3\u8a00\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30fb \u5ba3\u8a00\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u5ba3\u8a00\u306f\u3001\u30b3\u30f3\u30d1\u30cb\u30aa\u30f3\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u8cac\u4efb\u3067\u3059\u3002<\/p>\n<p>\u30fb \u30ac\u30fc\u30c9\u30b5\u30fc\u30d3\u30b9\u3092\u304a\u6301\u3061\u306e\u5834\u5408\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u30e2\u30b8\u30e5\u30fc\u30eb\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \uff08\u3053\u306e\u4f8b\u3067\u306f\u4f55\u3082\u3042\u308a\u307e\u305b\u3093\u3002\uff09<\/p>\n<h5>Update AppModule<\/h5>\n<p>ppModule\u304b\u3089\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u8a2d\u5b9a\u3092\u524a\u9664\u3057\u3001<strong>AppRoutingModule<\/strong>\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002 <\/p>\n<p>ES\u306e\u30a4\u30f3\u30dd\u30fc\u30c8\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3001<strong>NgModule.imports<\/strong>\u30ea\u30b9\u30c8\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u524d\u306e\u72b6\u614b\u3068\u6bd4\u8f03\u3057\u3066\u3001\u6539\u8a02\u3055\u308c\u305f<strong>AppModule<\/strong>\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n<p><strong>src\/app\/app.module.ts(after)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import { NgModule }       from '@angular\/core';\r\nimport { BrowserModule }  from '@angular\/platform-browser';\r\nimport { FormsModule }    from '@angular\/forms';\r\nimport { AppComponent }         from '.\/app.component';\r\nimport { DashboardComponent }   from '.\/dashboard.component';\r\nimport { HeroDetailComponent }  from '.\/hero-detail.component';\r\nimport { HeroesComponent }      from '.\/heroes.component';\r\nimport { HeroService }          from '.\/hero.service';\r\nimport { AppRoutingModule }     from '.\/app-routing.module';\r\n@NgModule({\r\n  imports: &#x5B;\r\n    BrowserModule,\r\n    FormsModule,\r\n    AppRoutingModule\r\n  ],\r\n  declarations: &#x5B;\r\n    AppComponent,\r\n    DashboardComponent,\r\n    HeroDetailComponent,\r\n    HeroesComponent\r\n  ],\r\n  providers: &#x5B; HeroService ],\r\n  bootstrap: &#x5B; AppComponent ]\r\n})\r\nexport class AppModule { }<\/pre>\n<p><strong>src\/app\/app.module.ts(before)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import { NgModule }       from '@angular\/core';\r\nimport { BrowserModule }  from '@angular\/platform-browser';\r\nimport { FormsModule }    from '@angular\/forms';\r\nimport { RouterModule }   from '@angular\/router';\r\nimport { AppComponent }        from '.\/app.component';\r\nimport { HeroDetailComponent } from '.\/hero-detail.component';\r\nimport { DashboardComponent }  from '.\/dashboard.component';\r\nimport { HeroesComponent }     from '.\/heroes.component';\r\nimport { HeroService }         from '.\/hero.service';\r\n@NgModule({\r\n  imports: &#x5B;\r\n    BrowserModule,\r\n    FormsModule,\r\n    RouterModule.forRoot(&#x5B;\r\n      {\r\n        path: '',\r\n        redirectTo: '\/dashboard',\r\n        pathMatch: 'full'\r\n      },\r\n      {\r\n        path: 'dashboard',\r\n        component: DashboardComponent\r\n      },\r\n      {\r\n        path: 'detail\/:id',\r\n        component: HeroDetailComponent\r\n      },\r\n      {\r\n        path: 'heroes',\r\n        component: HeroesComponent\r\n      }\r\n    ])\r\n  ],\r\n  declarations: &#x5B;\r\n    AppComponent,\r\n    DashboardComponent,\r\n    HeroDetailComponent,\r\n    HeroesComponent\r\n  ],\r\n  providers: &#x5B;\r\n    HeroService\r\n  ],\r\n  bootstrap: &#x5B; AppComponent ]\r\n})\r\nexport class AppModule {\r\n}<\/pre>\n<p><strong>AppModule<\/strong>\u306e\u6539\u8a02\u7248\u3068\u7c21\u7565\u7248\u306f\u3001\u30a2\u30d7\u30ea\u306e\u91cd\u8981\u306a\u90e8\u5206\u3092\u7279\u5b9a\u3059\u308b\u3053\u3068\u306b\u91cd\u70b9\u3092\u7f6e\u3044\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4>Select a hero in the HeroesComponent<\/h4>\n<p>HeroesComponent\u3067\u306f\u3001\u73fe\u5728\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u3001\u4e0b\u306e\u9078\u629e\u3055\u308c\u305f\u30d2\u30fc\u30ed\u30fc\u306e\u4e00\u756a\u4e0a\u306b\u30d2\u30fc\u30ed\u30fc\u306e\u30ea\u30b9\u30c8\u3068\u8a73\u7d30\u304c\u8868\u793a\u3055\u308c\u305f&#8221;master\/detail&#8221; \u30b9\u30bf\u30a4\u30eb\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">template: `\r\n  &lt;h1&gt;{{title}}&lt;\/h1&gt;\r\n  &lt;h2&gt;My Heroes&lt;\/h2&gt;\r\n  &lt;ul class=&quot;heroes&quot;&gt;\r\n    &lt;li *ngFor=&quot;let hero of heroes&quot;\r\n      &#x5B;class.selected]=&quot;hero === selectedHero&quot;\r\n      (click)=&quot;onSelect(hero)&quot;&gt;\r\n      &lt;span class=&quot;badge&quot;&gt;{{hero.id}}&lt;\/span&gt; {{hero.name}}\r\n    &lt;\/li&gt;\r\n  &lt;\/ul&gt;\r\n  &lt;hero-detail &#x5B;hero]=&quot;selectedHero&quot;&gt;&lt;\/hero-detail&gt;\r\n`,<\/pre>\n<p>\u4e0a\u90e8\u306e&lt;h1&gt;\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<p>&lt;hero-detail&gt;\u30bf\u30b0\u3067\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u6700\u5f8c\u306e\u884c\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f\u5b8c\u5168\u306a<strong>HeroDetailComponent<\/strong>\u306f\u8868\u793a\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u4ee3\u308f\u308a\u306b\u3001\u30d2\u30fc\u30ed\u30fc\u306e\u8a73\u7d30\u3092\u72ec\u81ea\u306e\u30da\u30fc\u30b8\u306b\u8868\u793a\u3057\u3001\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u3067\u884c\u3063\u305f\u3088\u3046\u306b\u30d2\u30fc\u30ed\u30fc\u306e\u8a73\u7d30\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30ea\u30b9\u30c8\u304b\u3089\u30d2\u30fc\u30ed\u30fc\u3092\u9078\u629e\u3059\u308b\u3068\u3001\u8a73\u7d30\u30da\u30fc\u30b8\u306b\u306f\u79fb\u52d5\u3057\u307e\u305b\u3093\u3002<\/p>\n<p>\u4ee3\u308f\u308a\u306b\u3001\u3053\u306e\u30da\u30fc\u30b8\u306e\u30df\u30cb\u30c7\u30a3\u30c6\u30fc\u30eb\u304c\u8868\u793a\u3055\u308c\u3001\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u5b8c\u5168\u306a\u8a73\u7d30\u30da\u30fc\u30b8\u306b\u79fb\u52d5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h5>Add the mini detail<\/h5>\n<p>&lt;hero-detail&gt;\u304c\u4f7f\u308f\u308c\u3066\u3044\u305f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u4e00\u756a\u4e0b\u306b\u6b21\u306eHTML\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/heroes.component.ts (mini-detail)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">&lt;div *ngIf=&quot;selectedHero&quot;&gt;\r\n  &lt;h2&gt;\r\n    {{selectedHero.name | uppercase}} is my hero\r\n  &lt;\/h2&gt;\r\n  &lt;button (click)=&quot;gotoDetail()&quot;&gt;View Details&lt;\/button&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>\u30d2\u30fc\u30ed\u30fc\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u30d2\u30fc\u30ed\u30fc\u30ea\u30b9\u30c8\u306e\u4e0b\u306b\u6b21\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/04\/mini-hero-detail.png\" alt=\"\" width=\"309\" height=\"103\" class=\"alignnone size-full wp-image-7780\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/04\/mini-hero-detail.png 309w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/04\/mini-hero-detail-300x100.png 300w\" sizes=\"auto, (max-width: 309px) 100vw, 309px\" \/><\/p>\n<h5>Format with the uppercase pipe<\/h5>\n<p>\u30d2\u30fc\u30ed\u30fc\u306e\u540d\u524d\u306f\u3001\u30d1\u30a4\u30d7\u6f14\u7b97\u5b50\uff08|\uff09\u306e\u76f4\u5f8c\u306e\u88dc\u9593\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306b\u542b\u307e\u308c\u308b\u5927\u6587\u5b57\u306e\u30d1\u30a4\u30d7\u306e\u305f\u3081\u3001\u5927\u6587\u5b57\u3067\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">{{selectedHero.name | uppercase}} is my hero<\/pre>\n<p>\u30d1\u30a4\u30d7\u306f\u3001\u6587\u5b57\u5217\u3001\u901a\u8ca8\u91d1\u984d\u3001\u65e5\u4ed8\u306a\u3069\u306e\u8868\u793a\u30c7\u30fc\u30bf\u3092\u66f8\u5f0f\u8a2d\u5b9a\u3059\u308b\u306e\u306b\u9069\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3044\u304f\u3064\u304b\u306e\u30d1\u30a4\u30d7\u304c\u4ed8\u3044\u3066\u3044\u308b\u3001<strong>Angular ships<\/strong>\u306f\u3042\u306a\u305f\u81ea\u8eab\u3067\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>&#8220;&#8220;&#8220;<br \/>\nRead more about pipes on the <a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/pipes.html\" target=\"_blank\">Pipes<\/a> page.<br \/>\n&#8220;&#8220;&#8220;<\/p>\n<p><strong>\u30fb \u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u79fb\u52d5\u3059\u308b<\/strong><\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u304c\u300c\u8a73\u7d30\u3092\u8868\u793a\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u3068\u304d\u306b <strong>HeroDetailComponent<\/strong>\u3078\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u3092\u30b5\u30dd\u30fc\u30c8\u3059\u308b\u305f\u3081\u306b\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30af\u30e9\u30b9\u3092\u66f4\u65b0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30d5\u30a1\u30a4\u30eb\u304c\u5927\u304d\u3044\u3067\u3059\u3002 <\/p>\n<p>HTML\u3084CSS\u306e\u30ce\u30a4\u30ba\u306e\u4e2d\u3067\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u30ed\u30b8\u30c3\u30af\u3092\u898b\u3064\u3051\u308b\u306e\u306f\u96e3\u3057\u3044\u3067\u3059\u3002<\/p>\n<p>\u5909\u66f4\u3092\u52a0\u3048\u308b\u524d\u306b\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u30b9\u30bf\u30a4\u30eb\u3092\u305d\u308c\u305e\u308c\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u79fb\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u307e\u305a\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u3092 <strong>heroes.component.ts<\/strong>\u304b\u3089\u65b0\u3057\u3044 <strong>heroes.component.htm<\/strong>l\u30d5\u30a1\u30a4\u30eb\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002\u30d0\u30c3\u30af\u30af\u30c3\u30af\u3092\u30b3\u30d4\u30fc\u3057\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002 <\/p>\n<p><strong>heroes.component.ts<\/strong>\u306b\u95a2\u3057\u3066\u306f\u3001\u3042\u306a\u305f\u306f\u3059\u3050\u306b\u305d\u308c\u306b\u623b\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001\u30b9\u30bf\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u65b0\u3057\u3044 <strong>heroes.component.css<\/strong>\u30d5\u30a1\u30a4\u30eb\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p>2\u3064\u306e\u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/heroes.component.html<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;h2&gt;My Heroes&lt;\/h2&gt;\r\n&lt;ul class=&quot;heroes&quot;&gt;\r\n  &lt;li *ngFor=&quot;let hero of heroes&quot;\r\n    &#x5B;class.selected]=&quot;hero === selectedHero&quot;\r\n    (click)=&quot;onSelect(hero)&quot;&gt;\r\n    &lt;span class=&quot;badge&quot;&gt;{{hero.id}}&lt;\/span&gt; {{hero.name}}\r\n  &lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n&lt;div *ngIf=&quot;selectedHero&quot;&gt;\r\n  &lt;h2&gt;\r\n    {{selectedHero.name | uppercase}} is my hero\r\n  &lt;\/h2&gt;\r\n  &lt;button (click)=&quot;gotoDetail()&quot;&gt;View Details&lt;\/button&gt;\r\n&lt;\/div&gt;<\/pre>\n<p><strong>src\/app\/heroes.component.css<\/strong><\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">.selected {\r\n  background-color: #CFD8DC !important;\r\n  color: white;\r\n}\r\n.heroes {\r\n  margin: 0 0 2em 0;\r\n  list-style-type: none;\r\n  padding: 0;\r\n  width: 15em;\r\n}\r\n.heroes li {\r\n  cursor: pointer;\r\n  position: relative;\r\n  left: 0;\r\n  background-color: #EEE;\r\n  margin: .5em;\r\n  padding: .3em 0;\r\n  height: 1.6em;\r\n  border-radius: 4px;\r\n}\r\n.heroes li:hover {\r\n  color: #607D8B;\r\n  background-color: #DDD;\r\n  left: .1em;\r\n}\r\n.heroes li.selected:hover {\r\n  background-color: #BBD8DC !important;\r\n  color: white;\r\n}\r\n.heroes .text {\r\n  position: relative;\r\n  top: -3px;\r\n}\r\n.heroes .badge {\r\n  display: inline-block;\r\n  font-size: small;\r\n  color: white;\r\n  padding: 0.8em 0.7em 0 0.7em;\r\n  background-color: #607D8B;\r\n  line-height: 1em;\r\n  position: relative;\r\n  left: -1px;\r\n  top: -4px;\r\n  height: 1.8em;\r\n  margin-right: .8em;\r\n  border-radius: 4px 0 0 4px;\r\n}\r\nbutton {\r\n  font-family: Arial;\r\n  background-color: #eee;\r\n  border: none;\r\n  padding: 5px 10px;\r\n  border-radius: 4px;\r\n  cursor: pointer;\r\n  cursor: hand;\r\n}\r\nbutton:hover {\r\n  background-color: #cfd8dc;\r\n}<\/pre>\n<p>\u6b21\u306b\u3001<strong>heroes.component.ts<\/strong>\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30e1\u30bf\u30c7\u30fc\u30bf\u306b\u623b\u3063\u3066\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u30b9\u30bf\u30a4\u30eb\u3092\u524a\u9664\u3057\u3001\u305d\u308c\u305e\u308ctemplateUrl\u3068styleUrls\u306b\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<p>\u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u3092\u53c2\u7167\u3059\u308b\u3088\u3046\u306b\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/heroes.component.ts (revised metadata)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">@Component({\r\n  selector: 'my-heroes',\r\n  templateUrl: '.\/heroes.component.html',\r\n  styleUrls: &#x5B; '.\/heroes.component.css' ]\r\n})<\/pre>\n<p>&#8220;&#8220;&#8220;<br \/>\nstyleUrls\u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u3001\u30b9\u30bf\u30a4\u30eb\u30d5\u30a1\u30a4\u30eb\u540d\u306e\u914d\u5217\u3067\u3059\uff08\u30d1\u30b9\u3092\u4f7f\u7528\uff09\u3002\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u3001\u7570\u306a\u308b\u5834\u6240\u304b\u3089\u8907\u6570\u306e\u30b9\u30bf\u30a4\u30eb\u30d5\u30a1\u30a4\u30eb\u3092\u30ea\u30b9\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n&#8220;&#8220;&#8220;<\/p>\n<h5>Update the HeroesComponent class<\/h5>\n<p><strong>HeroesComponent<\/strong>\u306f\u3001\u30dc\u30bf\u30f3\u30af\u30ea\u30c3\u30af\u306b\u5fdc\u7b54\u3057\u3066<strong>HeroesDetailComponent<\/strong>\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p>\u30dc\u30bf\u30f3\u306eclick\u30a4\u30d9\u30f3\u30c8\u306f\u3001\u3069\u3053\u306b\u884c\u304f\u3079\u304d\u304b\u3092\u30eb\u30fc\u30bf\u306b\u4f1d\u3048\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u547d\u4ee4\u7684\u306b\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308bgotoDetail\uff08\uff09\u30e1\u30bd\u30c3\u30c9\u306b\u30d0\u30a4\u30f3\u30c9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u3067\u306f\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30af\u30e9\u30b9\u306b\u4ee5\u4e0b\u306e\u5909\u66f4\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p><strong>Angular router<\/strong> \u30e9\u30a4\u30d6\u30e9\u30ea\u304b\u3089\u30eb\u30fc\u30bf\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p><strong>HeroService<\/strong>\u3068\u5171\u306b\u30eb\u30fc\u30bf\u3092\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306b\u6ce8\u5165\u3057\u307e\u3059\u3002<\/p>\n<p>router.navigate\uff08\uff09\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u3001gotoDetail\uff08\uff09\u3092\u5b9f\u88c5\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/heroes.component.ts (gotoDetail)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">gotoDetail(): void {\r\n  this.router.navigate(&#x5B;'\/detail', this.selectedHero.id]);\r\n}<\/pre>\n<p><strong>DashboardComponent<\/strong>\u306e[routerLink]\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3068\u540c\u3058\u3088\u3046\u306b\u30012\u8981\u7d20\u306e\u30ea\u30f3\u30af\u30d1\u30e9\u30e1\u30fc\u30bf\u914d\u5217\uff08\u30d1\u30b9\u3068\u30eb\u30fc\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\uff09\u3092router.navigate\uff08\uff09\u30e1\u30bd\u30c3\u30c9\u306b\u6e21\u3057\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u6539\u8a02\u3055\u308c\u305f <strong>HeroesComponent<\/strong>\u30af\u30e9\u30b9\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n<p><strong>src\/app\/heroes.component.ts (class)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">export class HeroesComponent implements OnInit {\r\n  heroes: Hero&#x5B;];\r\n  selectedHero: Hero;\r\n\r\n  constructor(\r\n    private router: Router,\r\n    private heroService: HeroService) { }\r\n\r\n  getHeroes(): void {\r\n    this.heroService.getHeroes().then(heroes =&gt; this.heroes = heroes);\r\n  }\r\n\r\n  ngOnInit(): void {\r\n    this.getHeroes();\r\n  }\r\n\r\n  onSelect(hero: Hero): void {\r\n    this.selectedHero = hero;\r\n  }\r\n\r\n  gotoDetail(): void {\r\n    this.router.navigate(&#x5B;'\/detail', this.selectedHero.id]);\r\n  }\r\n}<\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u3092\u66f4\u65b0\u3057\u3066\u3001\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u306f\u3001\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u304b\u3089\u30d2\u30fc\u30ed\u30fc\u306e\u8a73\u7d30\u307e\u3067\u3001\u30d2\u30fc\u30ed\u30fc\u30ea\u30b9\u30c8\u304b\u3089\u30df\u30cb\u30c7\u30a3\u30c6\u30fc\u30eb\u3001\u30d2\u30fc\u30ed\u30fc\u306e\u8a73\u7d30\u307e\u3067\u3001\u305d\u3057\u3066\u30d2\u30fc\u30ed\u30fc\u306b\u518d\u3073\u623b\u3063\u3066\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5468\u308a\u3092\u30ca\u30d3\u30b2\u30fc\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30da\u30fc\u30b8\u3092\u63a8\u9032\u3057\u305f\u3059\u3079\u3066\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u8981\u4ef6\u3092\u6e80\u305f\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4>Style the app<\/h4>\n<p>\u30a2\u30d7\u30ea\u306f\u6a5f\u80fd\u7684\u3067\u3059\u304c\u3001\u30b9\u30bf\u30a4\u30ea\u30f3\u30b0\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p>\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u30d2\u30fc\u30ed\u30fc\u306f\u9577\u65b9\u5f62\u306e\u5217\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u30c7\u30b6\u30a4\u30f3\u306e\u305f\u3081\u306e\u30b7\u30f3\u30d7\u30eb\u306a\u30e1\u30c7\u30a3\u30a2\u30af\u30a8\u30ea\u3092\u542b\u3080\u3001\u3053\u306e\u76ee\u7684\u306e\u305f\u3081\u306b\u7d0460\u884c\u306eCSS\u3092\u53d7\u3051\u53d6\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3042\u306a\u305f\u304c\u4eca\u77e5\u3063\u3066\u3044\u308b\u3088\u3046\u306b\u3001CSS\u3092\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30b9\u30bf\u30a4\u30eb\u306e\u30e1\u30bf\u30c7\u30fc\u30bf\u306b\u8ffd\u52a0\u3059\u308b\u3068\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30ed\u30b8\u30c3\u30af\u304c\u4e0d\u660e\u77ad\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4ee3\u308f\u308a\u306b\u3001\u5225\u306e* .css\u30d5\u30a1\u30a4\u30eb\u3067CSS\u3092\u7de8\u96c6\u3057\u307e\u3059\u3002<\/p>\n<p><strong>dashboard.component.css<\/strong>\u30d5\u30a1\u30a4\u30eb\u3092app\u30d5\u30a9\u30eb\u30c0\u306b\u8ffd\u52a0\u3057\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30e1\u30bf\u30c7\u30fc\u30bf\u306estyleUrls\u914d\u5217\u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u305d\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u6b21\u306e\u3088\u3046\u306b\u53c2\u7167\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/dashboard.component.ts (styleUrls)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">styleUrls: &#x5B; '.\/dashboard.component.css' ]<\/pre>\n<h5>Add stylish hero details<\/h5>\n<p><strong>HeroDetailComponent<\/strong>\u5c02\u7528\u306eCSS\u30b9\u30bf\u30a4\u30eb\u3082\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>hero-detail.component.css<\/strong>\u3092app\u30d5\u30a9\u30eb\u30c0\u306b\u8ffd\u52a0\u3057\u3001<strong>DashboardComponent<\/strong>\u306e\u5834\u5408\u3068\u540c\u69d8\u306bstyleUrls\u914d\u5217\u5185\u306e\u305d\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u53c2\u7167\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001<strong>hero-detail.component.ts<\/strong>\u3067\u306f\u3001\u30d2\u30fc\u30ed\u30fc\u30d7\u30ed\u30d1\u30c6\u30a3@Input\u30c7\u30b3\u30ec\u30fc\u30bf\u3068\u305d\u306e\u30a4\u30f3\u30dd\u30fc\u30c8\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u306b\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306eCSS\u30d5\u30a1\u30a4\u30eb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/hero-detail.component.css<\/strong><\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">label {\r\n  display: inline-block;\r\n  width: 3em;\r\n  margin: .5em 0;\r\n  color: #607D8B;\r\n  font-weight: bold;\r\n}\r\ninput {\r\n  height: 2em;\r\n  font-size: 1em;\r\n  padding-left: .4em;\r\n}\r\nbutton {\r\n  margin-top: 20px;\r\n  font-family: Arial;\r\n  background-color: #eee;\r\n  border: none;\r\n  padding: 5px 10px;\r\n  border-radius: 4px;\r\n  cursor: pointer; cursor: hand;\r\n}\r\nbutton:hover {\r\n  background-color: #cfd8dc;\r\n}\r\nbutton:disabled {\r\n  background-color: #eee;\r\n  color: #ccc; \r\n  cursor: auto;\r\n}<\/pre>\n<p><strong>src\/app\/dashboard.component.css<\/strong><\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">&#x5B;class*='col-'] {\r\n  float: left;\r\n  padding-right: 20px;\r\n  padding-bottom: 20px;\r\n}\r\n&#x5B;class*='col-']:last-of-type {\r\n  padding-right: 0;\r\n}\r\na {\r\n  text-decoration: none;\r\n}\r\n*, *:after, *:before {\r\n  -webkit-box-sizing: border-box;\r\n  -moz-box-sizing: border-box;\r\n  box-sizing: border-box;\r\n}\r\nh3 {\r\n  text-align: center; margin-bottom: 0;\r\n}\r\nh4 {\r\n  position: relative;\r\n}\r\n.grid {\r\n  margin: 0;\r\n}\r\n.col-1-4 {\r\n  width: 25%;\r\n}\r\n.module {\r\n  padding: 20px;\r\n  text-align: center;\r\n  color: #eee;\r\n  max-height: 120px;\r\n  min-width: 120px;\r\n  background-color: #607D8B;\r\n  border-radius: 2px;\r\n}\r\n.module:hover {\r\n  background-color: #EEE;\r\n  cursor: pointer;\r\n  color: #607d8b;\r\n}\r\n.grid-pad {\r\n  padding: 10px 0;\r\n}\r\n.grid-pad &gt; &#x5B;class*='col-']:last-of-type {\r\n  padding-right: 20px;\r\n}\r\n@media (max-width: 600px) {\r\n  .module {\r\n    font-size: 10px;\r\n    max-height: 75px; }\r\n}\r\n@media (max-width: 1024px) {\r\n  .grid {\r\n    margin: 0;\r\n  }\r\n  .module {\r\n    min-width: 60px;\r\n  }\r\n}<\/pre>\n<h5>Style the navigation links<\/h5>\n<p>\u63d0\u4f9b\u3055\u308c\u305fCSS\u306f\u3001<strong>AppComponent<\/strong>\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30ea\u30f3\u30af\u3092\u9078\u629e\u53ef\u80fd\u306a\u30dc\u30bf\u30f3\u306e\u3088\u3046\u306b\u898b\u305b\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306e\u30ea\u30f3\u30af\u306f\u3001&lt;nav&gt;\u30bf\u30b0\u3067\u56f2\u307f\u307e\u3059\u3002<\/p>\n<p><strong>app.component.css<\/strong>\u30d5\u30a1\u30a4\u30eb\u3092\u3001\u6b21\u306e\u5185\u5bb9\u306eapp\u30d5\u30a9\u30eb\u30c0\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app.component.css (navigation styles)<\/strong><\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">h1 {\r\n  font-size: 1.2em;\r\n  color: #999;\r\n  margin-bottom: 0;\r\n}\r\nh2 {\r\n  font-size: 2em;\r\n  margin-top: 0;\r\n  padding-top: 0;\r\n}\r\nnav a {\r\n  padding: 5px 10px;\r\n  text-decoration: none;\r\n  margin-top: 10px;\r\n  display: inline-block;\r\n  background-color: #eee;\r\n  border-radius: 4px;\r\n}\r\nnav a:visited, a:link {\r\n  color: #607D8B;\r\n}\r\nnav a:hover {\r\n  color: #039be5;\r\n  background-color: #CFD8DC;\r\n}\r\nnav a.active {\r\n  color: #039be5;\r\n}<\/pre>\n<p>&#8220;&#8220;&#8220;<br \/>\n<strong>The routerLinkActive directive<\/strong><\/p>\n<p>Angular router \u306f\u3001<strong>routerLinkActive<\/strong>\u6307\u4ee4\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u6307\u4ee4\u3092\u4f7f\u7528\u3057\u3066\u3001\u30eb\u30fc\u30c8\u304c\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30eb\u30fc\u30c8\u3068\u4e00\u81f4\u3059\u308bHTML\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u8981\u7d20\u306b\u30af\u30e9\u30b9\u3092\u8ffd\u52a0\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3042\u306a\u305f\u304c\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3053\u3068\u306f\u3001\u305d\u306e\u30b9\u30bf\u30a4\u30eb\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u3060\u3051\u3067\u3059\u3002<\/p>\n<p><strong>src\/app\/app.component.ts (active router links)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">template: `\r\n  &lt;h1&gt;{{title}}&lt;\/h1&gt;\r\n  &lt;nav&gt;\r\n    &lt;a routerLink=&quot;\/dashboard&quot; routerLinkActive=&quot;active&quot;&gt;Dashboard&lt;\/a&gt;\r\n    &lt;a routerLink=&quot;\/heroes&quot; routerLinkActive=&quot;active&quot;&gt;Heroes&lt;\/a&gt;\r\n  &lt;\/nav&gt;\r\n  &lt;router-outlet&gt;&lt;\/router-outlet&gt;\r\n`,<\/pre>\n<p>&#8220;&#8220;&#8220;<\/p>\n<p>\u3053\u306eCSS\u30d5\u30a1\u30a4\u30eb\u3092\u53c2\u7167\u3059\u308b\u3001<strong>styleUrls<\/strong>\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6b21\u306e\u3088\u3046\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><strong>src\/app\/app.component.ts (styleUrls)<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">styleUrls: &#x5B;'.\/app.component.css'],<\/pre>\n<h5>Global application styles<\/h5>\n<p>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u30b9\u30bf\u30a4\u30eb\u3092\u8ffd\u52a0\u3059\u308b\u3068\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u5fc5\u8981\u3068\u3059\u308b\u3059\u3079\u3066\u306e\u3082\u306e\u3001\u3064\u307e\u308aHTML\u3001CSS\u3001\u30b3\u30fc\u30c9\u30921\u3064\u306e\u4fbf\u5229\u306a\u5834\u6240\u306b\u4fdd\u5b58\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3059\u3079\u3066\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30d1\u30c3\u30b1\u30fc\u30b8\u5316\u3057\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u5225\u306e\u5834\u6240\u3067\u518d\u5229\u7528\u3059\u308b\u306e\u306f\u7c21\u5358\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5916\u306b\u3042\u308b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30ec\u30d9\u30eb\u3067\u30b9\u30bf\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30b6\u30a4\u30ca\u30fc\u306f\u3001\u30a2\u30d7\u30ea\u5168\u4f53\u306e\u8981\u7d20\u306b\u9069\u7528\u3059\u308b\u305f\u3081\u306e\u57fa\u672c\u7684\u306a\u30b9\u30bf\u30a4\u30eb\u3092\u3044\u304f\u3064\u304b\u7528\u610f\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u308c\u3089\u306f\u3001<a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/setup.html\" target=\"_blank\">\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u4e2d<\/a>\u306b\u4ee5\u524d\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u4e00\u9023\u306e\u30de\u30b9\u30bf\u30fc\u30b9\u30bf\u30a4\u30eb\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u306b\u629c\u7c8b\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n<p><strong>src\/styles.css (excerpt)<\/strong><\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\/* Master Styles *\/\r\nh1 {\r\n  color: #369;\r\n  font-family: Arial, Helvetica, sans-serif;\r\n  font-size: 250%;\r\n}\r\nh2, h3 {\r\n  color: #444;\r\n  font-family: Arial, Helvetica, sans-serif;\r\n  font-weight: lighter;\r\n}\r\nbody {\r\n  margin: 2em;\r\n}\r\nbody, input&#x5B;text], button {\r\n  color: #888;\r\n  font-family: Cambria, Georgia;\r\n}\r\n\/* . . . *\/\r\n\/* everywhere else *\/\r\n* {\r\n  font-family: Arial, Helvetica, sans-serif;\r\n}<\/pre>\n<p>styles.css\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u306b\u3053\u3053\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b<a href=\"https:\/\/raw.githubusercontent.com\/angular\/angular.io\/master\/public\/docs\/_examples\/_boilerplate\/src\/styles.css\" target=\"_blank\">\u30de\u30b9\u30bf\u30fc\u30b9\u30bf\u30a4\u30eb<\/a>\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u3053\u306e\u30b9\u30bf\u30a4\u30eb\u30b7\u30fc\u30c8\u3092\u53c2\u7167\u3059\u308b\u305f\u3081\u306b\u3001<strong>index.html<\/strong>\u3092\u7de8\u96c6\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>src\/index.html (link ref)<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;link rel=&quot;stylesheet&quot; href=&quot;styles.css&quot;&gt;<\/pre>\n<p>\u4eca\u3001\u30a2\u30d7\u30ea\u3092\u898b\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u3001\u30d2\u30fc\u30ed\u30fc\u3001\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30ea\u30f3\u30af\u306f\u30b9\u30bf\u30a4\u30ea\u30f3\u30b0\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/04\/dashboard-top-heroes.png\" alt=\"\" width=\"694\" height=\"226\" class=\"alignnone size-full wp-image-7782\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/04\/dashboard-top-heroes.png 694w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/04\/dashboard-top-heroes-300x98.png 300w\" sizes=\"auto, (max-width: 694px) 100vw, 694px\" \/><\/p>\n<h4>Application structure and code<\/h4>\n<p>\u3053\u306e\u30da\u30fc\u30b8\u306e <a href=\"https:\/\/angular.io\/resources\/live-examples\/toh-5\/ts\/eplnkr.html\" target=\"_blank\">live example<\/a> \/ <a href=\"https:\/\/angular.io\/resources\/zips\/toh-5\/toh-5.zip\" target=\"_blank\">downloadable example<\/a> \u306e\u30b5\u30f3\u30d7\u30eb\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u6b21\u306e\u69cb\u9020\u3092\u6301\u3063\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">angular-tour-of-heroes\r\n\u251c\u2500\u2500src\r\n\u2502 \u251c\u2500\u2500app\r\n\u2502 \u2502  \u251c\u2500\u2500app.component.css\r\n\u2502 \u2502  \u251c\u2500\u2500app.component.ts\r\n\u2502 \u2502  \u251c\u2500\u2500app-routing.module.ts\r\n\u2502 \u2502  \u251c\u2500\u2500dashboard.component.css\r\n\u2502 \u2502  \u251c\u2500\u2500dashboard.component.html\r\n\u2502 \u2502  \u251c\u2500\u2500dashboard.component.ts\r\n\u2502 \u2502  \u251c\u2500\u2500hero.service.ts\r\n\u2502 \u2502  \u251c\u2500\u2500hero.ts\r\n\u2502 \u2502  \u251c\u2500\u2500hero-detail.component.html\r\n\u2502 \u2502  \u251c\u2500\u2500hero-detail.component.css\r\n\u2502 \u2502  \u251c\u2500\u2500hero-detail.component.ts\r\n\u2502 \u2502  \u251c\u2500\u2500heroes.component.css\r\n\u2502 \u2502  \u251c\u2500\u2500heroes.component.html\r\n\u2502 \u2502  \u251c\u2500\u2500heroes.component.ts\r\n\u2502 \u2502  \u2514\u2500\u2500mock-heroes.ts\r\n\u2502 \u251c\u2500\u2500main.ts\r\n\u2502 \u251c\u2500\u2500index.html\r\n\u2502 \u251c\u2500\u2500styles.css\r\n\u2502 \u251c\u2500\u2500systemjs.config.js\r\n\u2502 \u2514\u2500\u2500tsconfig.json\r\n\u251c\u2500\u2500node_modules ...\r\n\u2514\u2500\u2500package.json<\/pre>\n<h4>The road you\u2019ve travelled<\/h4>\n<p>\u3053\u306e\u30da\u30fc\u30b8\u3067\u3042\u306a\u305f\u304c\u9054\u6210\u3057\u305f\u3053\u3068\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<p>\u30fb \u3055\u307e\u3056\u307e\u306a\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u9593\u3092\u79fb\u52d5\u3059\u308b\u305f\u3081\u306b\u3001 Angular router\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u30fb \u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30e1\u30cb\u30e5\u30fc\u9805\u76ee\u3092\u8868\u3059\u305f\u3081\u306e\u30eb\u30fc\u30bf\u30fc\u30ea\u30f3\u30af\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5\u3092\u5b66\u3073\u307e\u3057\u305f\u3002<\/p>\n<p>\u30fb \u30eb\u30fc\u30bf\u30ea\u30f3\u30af\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u3001\u30e6\u30fc\u30b6\u304c\u9078\u629e\u3057\u305f\u30d2\u30fc\u30ed\u30fc\u306e\u8a73\u7d30\u306b\u79fb\u52d5\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u30fb \u3042\u306a\u305f\u306f\u3001\u8907\u6570\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u9593\u3067\u3001<strong>HeroService<\/strong>\u3092\u5171\u6709\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u30fb HTML\u3068CSS\u3092\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u81ea\u5206\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u79fb\u52d5\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u30fb \u30c7\u30fc\u30bf\u3092\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3059\u308b\u305f\u3081\u306b\u5927\u6587\u5b57\u306e\u30d1\u30a4\u30d7\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3042\u306a\u305f\u306e\u30a2\u30d7\u30ea\u306f\u3053\u306e <a href=\"https:\/\/angular.io\/resources\/live-examples\/toh-5\/ts\/eplnkr.html\" target=\"_blank\">live example<\/a> \/ <a href=\"https:\/\/angular.io\/resources\/zips\/toh-5\/toh-5.zip\" target=\"_blank\">downloadable example.<\/a>\u306e\u3088\u3046\u306b\u898b\u3048\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<h5>The road ahead<\/h5>\n<p>\u3042\u306a\u305f\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u57fa\u76e4\u306e\u591a\u304f\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3042\u306a\u305f\u306f\u307e\u3060\u91cd\u8981\u306a\u90e8\u5206\u3092\u6b20\u3044\u3066\u3044\u307e\u3059\u3002 \u305d\u308c\u306f\u3001<strong>remote data access<\/strong>\u3067\u3059\u3002<\/p>\n<p>\u6b21\u306e\u30da\u30fc\u30b8\u3067\u306f\u3001http\u3092\u4f7f\u7528\u3057\u3066\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3067\u3001\u6a21\u64ec\u30c7\u30fc\u30bf\u3092\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<h4>Next Step<\/h4>\n<p><a href=\"https:\/\/www.webcyou.com\/?p=7523\">Angular2\u306e\u59cb\u3081\u65b9\u3002Angular2 \u516c\u5f0f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb \u2013 HTTP\uff08\u7c21\u5358\u306a\u548c\u8a33\uff09<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ROUTING \u3053\u3061\u3089\u306e\u30da\u30fc\u30b8\u306f\u3001\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u306e\u7c21\u5358\u306a\u548c\u8a33\u3067\u3059\u3002 Angular2 tutorial | ROUTING \u524d\u56de Angular2\u306e\u59cb\u3081\u65b9\u3002Angular2 \u516c\u5f0f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb \u2013 Services\uff08\u7c21\u5358\u306a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[203],"tags":[171,59,167,177,168,176,40,166,37,47,179,46,169,180,44,45,111,178,138,78,114,118],"class_list":{"0":"post-7521","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-angular2","7":"tag-android","8":"tag-android-sdk","9":"tag-css","10":"tag-css3","11":"tag-html","12":"tag-html5","13":"tag-ios-sdk","14":"tag-iphone","15":"tag-iphone-","16":"tag-javascript-2","17":"tag-jquery","18":"tag-js","19":"tag-mac","20":"tag-mysql","21":"tag-web","23":"tag-wordpress-2","24":"tag-178","25":"tag-138","26":"tag-78","27":"tag-114","28":"tag-118"},"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/7521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7521"}],"version-history":[{"count":22,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/7521\/revisions"}],"predecessor-version":[{"id":7798,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/7521\/revisions\/7798"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}