-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated demo app to use NgxMatTypeahead directive for typeahead funct…
…ionality
- Loading branch information
Showing
10 changed files
with
102 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,12 @@ | ||
<!--The content below is only a placeholder and can be replaced.--> | ||
<div style="text-align:center"> | ||
<h1> | ||
Welcome to {{ title }}! | ||
</h1> | ||
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg=="> | ||
<h3>Typeahead demo app using Angular Material</h3> | ||
<div [formGroup]="testFormGroup"> | ||
<mat-form-field> | ||
<input matInput NgxMatTypeahead (filteredDataList)="getFilteredSuggestions($event)" formControlName="country" [matAutocomplete]="countryAuto" | ||
placeholder="Choose Country"> | ||
<mat-autocomplete #countryAuto="matAutocomplete"> | ||
<mat-option *ngFor="let country of countries" [value]="country"> | ||
{{country}} | ||
</mat-option> | ||
</mat-autocomplete> | ||
</mat-form-field> | ||
</div> | ||
<h2>Here are some links to help you start: </h2> | ||
<ul> | ||
<li> | ||
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2> | ||
</li> | ||
<li> | ||
<h2><a target="_blank" rel="noopener" href="https://github.com/angular/angular-cli/wiki">CLI Documentation</a></h2> | ||
</li> | ||
<li> | ||
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2> | ||
</li> | ||
</ul> | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
import { Component, OnInit } from '@angular/core'; | ||
import { FormControl, FormGroup } from '@angular/forms'; | ||
import { AppService } from './app.service'; | ||
@Component({ | ||
selector: 'mat-ta-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.css'] | ||
}) | ||
export class AppComponent { | ||
title = 'mat-ta'; | ||
export class AppComponent implements OnInit { | ||
constructor(private appService: AppService) {} | ||
|
||
testFormGroup: FormGroup = new FormGroup({ country: new FormControl('') }); | ||
countries: Array<string> = []; | ||
|
||
ngOnInit() { | ||
this.appService.getCountries().subscribe(data => (this.countries = data)); | ||
} | ||
|
||
getFilteredSuggestions(filteredDataLst: Array<any>) { | ||
this.countries = [...filteredDataLst]; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { HttpClientModule } from '@angular/common/http'; | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { MatAutocompleteModule, MatInputModule } from '@angular/material'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { NgxMatTypeaheadModule } from 'NgxMatTypeahead'; | ||
import { AppComponent } from './app.component'; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
AppComponent | ||
], | ||
declarations: [AppComponent], | ||
imports: [ | ||
BrowserModule | ||
BrowserModule, | ||
BrowserAnimationsModule, | ||
FormsModule, | ||
ReactiveFormsModule, | ||
MatInputModule, | ||
MatAutocompleteModule, | ||
HttpClientModule, | ||
NgxMatTypeaheadModule | ||
], | ||
providers: [], | ||
bootstrap: [AppComponent] | ||
}) | ||
export class AppModule { } | ||
export class AppModule {} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class AppService { | ||
constructor(private http: HttpClient) {} | ||
|
||
getCountries(): Observable<Array<string>> { | ||
return this.http.get<Array<string>>('../assets/countries.json').pipe( | ||
map(data => { | ||
return data['countries']; | ||
}) | ||
); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"countries": ["United States", "United Kingdom", "China", "Japan", "India", "Russia", "Canada", "Brazil"] | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
/* You can add global styles to this file, and also import other style files */ | ||
|
||
body { | ||
margin: 20px; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,12 @@ | |
dependencies: | ||
tslib "^1.9.0" | ||
|
||
"@angular/cdk@^6.1.0": | ||
version "6.1.0" | ||
resolved "https://registry.yarnpkg.com/@angular/cdk/-/cdk-6.1.0.tgz#14ae46730315d40b5a642daa8f5f80815930085c" | ||
dependencies: | ||
tslib "^1.7.1" | ||
|
||
"@angular/cli@~6.0.3": | ||
version "6.0.3" | ||
resolved "https://registry.yarnpkg.com/@angular/cli/-/cli-6.0.3.tgz#a7a2defdaa2a9f2914aadb7e0a25d9a43d8346c4" | ||
|
@@ -166,6 +172,12 @@ | |
version "6.0.3" | ||
resolved "https://registry.yarnpkg.com/@angular/language-service/-/language-service-6.0.3.tgz#7182f3824520fd5f5f6173fdee80284356d29d08" | ||
|
||
"@angular/material@^6.1.0": | ||
version "6.1.0" | ||
resolved "https://registry.yarnpkg.com/@angular/material/-/material-6.1.0.tgz#c13f4fb38ae6f52c7c49cd8d3ae4baca4abd36ab" | ||
dependencies: | ||
tslib "^1.7.1" | ||
|
||
"@angular/platform-browser-dynamic@^6.0.2": | ||
version "6.0.3" | ||
resolved "https://registry.yarnpkg.com/@angular/platform-browser-dynamic/-/platform-browser-dynamic-6.0.3.tgz#b27e26c06df4ce34879cefd818e7ff394764f834" | ||
|
@@ -4042,18 +4054,14 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: | |
dependencies: | ||
brace-expansion "^1.1.7" | ||
|
||
[email protected]: | ||
[email protected], minimist@~0.0.1: | ||
version "0.0.8" | ||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" | ||
|
||
minimist@^1.1.0, minimist@^1.1.3, minimist@^1.2.0: | ||
version "1.2.0" | ||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" | ||
|
||
minimist@~0.0.1: | ||
version "0.0.10" | ||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" | ||
|
||
minipass@^2.2.1, minipass@^2.3.3: | ||
version "2.3.3" | ||
resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.3.3.tgz#a7dcc8b7b833f5d368759cce544dccb55f50f233" | ||
|