ã¯ããã«
ãAngularã¯ãGoogleã¨ãªã¼ãã³ã½ã¼ã¹ã³ãã¥ããã£ã§éçºããã¦ããJavaScriptãã¬ã¼ã ã¯ã¼ã¯ã§ããæåã®ãã¼ã¸ã§ã³ã¯AngularJSï¼AngularJS 1ï¼ã¨å¼ã°ãã¦ãã¾ãããããã¼ã¸ã§ã³2ã§å ¨é¢çã«å·æ°ããã以éãããããåå¹´ã«1åã¢ãããã¼ãããã¦ãã¾ãã
ããMaterial Designãã¯ãGoogleãæå±ãããã¶ã¤ã³ã¬ã¤ãã©ã¤ã³ã§ãGoogleã®ã¹ãã¼ããã©ã³ã¢ããªãªã©ã§å©ç¨ããã¦ãã¾ããæ¬è¨äºã§ç´¹ä»ãããAngular Materialãã¯ããã®Material Designã«å¯¾å¿ããUIé¨åãæä¾ãããAngularç¨ã³ã³ãã¼ãã³ãéã§ããAngular Materialãå©ç¨ããã°ãAngularã®Webãã¼ã¸ã«Material Designã®å¤è¦³ãæåãé©ç¨ã§ãã¾ãã
ãæ¬è¨äºã§ã¯ãAngularããã¸ã§ã¯ãã«Angular Materialãå°å ¥ãã¦å©ç¨ããæ¹æ³ã¨ãAngular Materialã®UIé¨åãå©ç¨ããä¾ãããµã³ãã«ã¨ã¨ãã«ç´¹ä»ãã¦ããã¾ãã
対象èªè
- Angularã®Webãã¼ã¸ã«çµ±ä¸çãªãã¶ã¤ã³ãé©ç¨ãããæ¹
- Googleã®ã¢ããªã®ãããªãã¶ã¤ã³ãèªåã®Webãã¼ã¸ã«ãå°å ¥ãããæ¹
- è¦æ ãã®è¯ãWebãã¼ã¸ãä½ãããæ¹
å¿ è¦ãªç°å¢
ãAngularã®éçºã§ã¯ãä¸è¬ã«TypeScriptï¼å¤æãã¦JavaScriptãçæãããããããAltJSè¨èªï¼ãå©ç¨ããã¾ããæ¬è¨äºã®ãµã³ãã«ã³ã¼ããTypeScriptã§è¨è¿°ãã¦ãã¾ãã
ãä»åã¯ä»¥ä¸ã®ç°å¢ã§åä½ã確èªãã¦ãã¾ããAngular Materialã®ã»ã¬ã¯ãããã¯ã¹ãMicrosoft Edgeã§æ£ãã表示ãããªãï¼æå³ãããã©ã¦ã¶ã¼ç»é¢ã®æ¨ªå¹ ãã£ã±ãã«è¡¨ç¤ºãããï¼ãããæ¬è¨äºã§ã¯Google Chromeãåä½ç¢ºèªã«ä½¿ç¨ãã¾ãã
-
Windows 10 64bitç ã
- Angular 7.2.12
- Angular Material 7.3.7
- Angular CLI 7.3.8
- Node.js v10.15.3 64bitç
- Google Chrome 73.0.3683.103
ããµã³ãã«ã³ã¼ããå®è¡ããã«ã¯ããµã³ãã«ã®ãã©ã«ãã¼ã§ãnpm installãã³ãã³ããå®è¡ãã¦ã©ã¤ãã©ãªããã¦ã³ãã¼ãå¾ããng serveãã³ãã³ããå®è¡ãã¦ãWebãã©ã¦ã¶ã¼ã§ãhttp://localhost:4200ããéãã¾ãããng serve --openãã¨ãªãã·ã§ã³æå®ããã¨ãå®è¡æã«Webãã©ã¦ã¶ã¼ãèªåã§èµ·åãã¦ãã¼ã¸ã表示ã§ãã¾ãã
Angular Materialã®å°å ¥ã¨ãåºæ¬çãªå©ç¨æ¹æ³
ãAngular Materialãå°å ¥ãã¦å©ç¨ããåºæ¬çãªæ¹æ³ãããã¼ã«ãã¼ï¼MatToolbarï¼ã表示ããå³2ã®ãµã³ãã«ã§èª¬æãã¾ãã
ãæåã«ããªã¹ã1ã®ã³ãã³ããå®è¡ãã¦ãAngular CLIã§Angularã®ããã¸ã§ã¯ããçæããAngular Materialãå°å ¥ãã¾ãã
ng new p001-basic #...ï¼1ï¼ cd p001-basic #...ï¼2ï¼ ng add @angular/material #...ï¼3ï¼
ãï¼1ï¼ã§ããã¸ã§ã¯ããçæå¾ãï¼2ï¼ã§ãã®ãã©ã«ãã¼ã«ç§»åãã¦ãï¼3ï¼ã®ng addã³ãã³ãã§Angular Materialãå°å ¥ãã¾ãããªããAngular 7以éã§ã¯ãï¼3ï¼ã®ã³ãã³ãå®è¡æã«ããã¼ãã«ã©ã¼ãªã©ãå¯¾è©±å ¥åã§æå®ã§ãã¾ãã詳細ã¯Angluar 7ã®ç´¹ä»è¨äºãé£è¼18åããã¬ã¼ã ã¯ã¼ã¯ã¨ãã¼ã«ã®ä¸¡é¢ã§å®æ度ã¢ããï¼ ãAngularããã¼ã¸ã§ã³7ã®æ°æ©è½ããåèã«ãã¦ãã ããã
ã次ã«ãAngular Materialã®ã¢ã¸ã¥ã¼ã«ãã¤ã³ãã¼ããã¾ããWebãã¼ã¸ã®ã«ã¼ãã¢ã¸ã¥ã¼ã«å®ç¾©ãã¡ã¤ã«ï¼app.module.tsï¼ã§ããã¼ã«ãã¼ã®ã¢ã¸ã¥ã¼ã«ï¼MatToolbarModuleï¼ãããªã¹ã2ï¼1ï¼ã§åç §ãã¦ãï¼2ï¼ã§ã¤ã³ãã¼ããã¾ããAngular Materialã®ã¢ã¸ã¥ã¼ã«ã¯æ©è½ãã¨ã«åããã¦ããã®ã§ãå¿ è¦ãªæ©è½ã®ã¢ã¸ã¥ã¼ã«ãã¤ã³ãã¼ããã¾ãã
import { MatToolbarModule } from '@angular/material'; // åç § ...ï¼1ï¼ ï¼ç¥ï¼ @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, MatToolbarModule // ã¤ã³ãã¼ã ...ï¼2ï¼ ], ï¼ç¥ï¼ }) export class AppModule { }
ãæå¾ã«ãWebãã¼ã¸ã®ã«ã¼ãã³ã³ãã¼ãã³ãã§ãAngular Materialã®ãã¼ã«ãã¼ã³ã³ãã¼ãã³ãã表ã<mat-toolbar>ãããã³ãã¬ã¼ãã«ãªã¹ã3ã®éãè¨è¿°ãã¾ãã
<mat-toolbar color="primary"> <span>ã¯ããã¦ã®Angular Material</span> </mat-toolbar>
ã<mat-toolbar>ã®colorå±æ§ã«æå®ããã¦ãããprimaryãã¯ãAngular Materialã®ãã¼ãã«ã©ã¼ã®ãã¡ãã¡ã¤ã³ã¨ãªãè²ã表ãã¾ãããã¼ãã«ã©ã¼ã«ã¯primary以å¤ã«accentï¼ã¢ã¯ã»ã³ãè²ï¼ãwarnï¼ã¨ã©ã¼ã表ãè²ï¼ãããã¾ãã