This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //in app.module.ts | |
| import { RouterModule } from '@angular/router'; | |
| imports: [ | |
| BrowserModule, | |
| FormsModule, | |
| HttpModule, | |
| RouterModule.forRoot([ | |
| { | |
| path: 'member', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //in app.component.ts | |
| export class AppComponent { | |
| title = 'app works!'; | |
| // Data array | |
| todoListData = ["aaa", "bbb", "ccc"]; | |
| inputText = ""; | |
| // function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // in html | |
| <form #userform = "ngForm" (ngSubmit) = "onSubmit(userform.value)"> | |
| <input name="first" ngModel required #first="ngModel"> | |
| <input type="text" placeholder="lastname" name="lastname" ngModel> | |
| <select name="lang" ngModel> | |
| <option value="a1">a1</option> | |
| <option value="a2">a2</option> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //in app.module.ts FormsModule -> ReactiveFormsModule | |
| import { ReactiveFormsModule } from '@angular/forms'; | |
| imports: [ | |
| BrowserModule, | |
| ReactiveFormsModule, | |
| HttpModule | |
| ], | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // cli | |
| ng g service myData | |
| //my-data.service.ts | |
| constructor() { } | |
| obj = { | |
| id:"1", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // create json file in assets folder | |
| // in app.module.ts | |
| import { HttpModule } from '@angular/http'; | |
| imports: [ | |
| BrowserModule, | |
| FormsModule, | |
| HttpModule | |
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //component.ts | |
| import { Component } from '@angular/core'; | |
| declare var foo: any; | |
| import '../assets/foo.js'; | |
| @Component({ | |
| selector: 'app-root', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //new project | |
| ng new gallery | |
| cd gallery | |
| ng g service imgData // generate service | |
| ng g c gallery // generate gallery component | |
| //copy images folder to src/assets | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //HTML | |
| <input type="text" [(ngModel)]="_num"/> | |
| <ul> | |
| <li *ngFor="let item of numList | numFilter:_num"> | |
| {{item.po}} | |
| </li> | |
| </ul> | |
| <p>_num:{{_num}}</p> |