Skip to content

Commit aa5a5f4

Browse files
committed
[Component] Add Typeahead component
1 parent 8b37cb4 commit aa5a5f4

File tree

6 files changed

+91
-0
lines changed

6 files changed

+91
-0
lines changed

src/renderer/app/layout/layout.routing.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ const LAYOUT_ROUTES: Routes = [
7878
{
7979
path: 'toasty',
8080
loadChildren: () => import('../pages/component/toasty/toasty.module').then(m => m.ToastyComponentModule)
81+
},
82+
{
83+
path: 'typeahead',
84+
loadChildren: () => import('../pages/component/typeahead/typeahead.module').then(m => m.TypeaheadComponentModule)
8185
}
8286
]
8387
},

src/renderer/app/layout/navigation/navigation.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
<li routerLinkActive="navigation__active">
5454
<a [routerLink]="['/component/toasty']"><i class="fa fa-newspaper-o"></i> Toasty</a>
5555
</li>
56+
<li routerLinkActive="navigation__active">
57+
<a [routerLink]="['/component/typeahead']"><i class="fa fa-tty"></i> Typeahead</a>
58+
</li>
5659
</ul>
5760
</li>
5861
<li routerLinkActive="navigation__sub--active" class="navigation__sub">
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<section class="content--row">
2+
<header class="content__title">
3+
<h1>Typeahead</h1>
4+
<small>This template is built using <code>ngx-bootstrap/typeahead</code> and provides some usage examples</small>
5+
</header>
6+
<div class="row">
7+
<div class="col-sm-6">
8+
<div class="card">
9+
<div class="card-body">
10+
<h4 class="card-title">Typeahead</h4>
11+
<div class="form-group">
12+
<input [(ngModel)]="selected" [typeahead]="states" class="form-control" placeholder="Enter S here">
13+
<i class="form-group__bar"></i>
14+
</div>
15+
<pre>Selected data: {{selected | json}}</pre>
16+
</div>
17+
</div>
18+
</div>
19+
</div>
20+
</section>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { AfterViewInit, Component } from '@angular/core';
2+
import { TypeaheadService } from '@renderer/services/component/typeahead.service';
3+
4+
@Component({
5+
selector: 'app-component-typeahead',
6+
templateUrl: './typeahead.component.html'
7+
})
8+
export class TypeaheadComponent implements AfterViewInit {
9+
selected: string;
10+
states: string[];
11+
12+
constructor(private typeaheadService: TypeaheadService) {
13+
}
14+
15+
ngAfterViewInit() {
16+
this.states = this.typeaheadService.states;
17+
}
18+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
3+
import { FormsModule } from '@angular/forms';
4+
import { RouterModule } from '@angular/router';
5+
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
6+
import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
7+
import { TypeaheadComponent } from './typeahead.component';
8+
import { TypeaheadService } from '@renderer/services/component/typeahead.service';
9+
10+
const TYPEAHEAD_ROUTES = [
11+
{path: '', component: TypeaheadComponent}
12+
];
13+
14+
@NgModule({
15+
declarations: [
16+
TypeaheadComponent
17+
],
18+
imports: [
19+
CommonModule,
20+
FormsModule,
21+
BsDropdownModule.forRoot(),
22+
TypeaheadModule.forRoot(),
23+
RouterModule.forChild(TYPEAHEAD_ROUTES)
24+
],
25+
providers: [
26+
TypeaheadService
27+
]
28+
})
29+
export class TypeaheadComponentModule {
30+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export class TypeaheadService {
2+
public states = [
3+
'A1',
4+
'A2',
5+
'A3',
6+
'S1',
7+
'S2',
8+
'S3',
9+
'Z1',
10+
'Z2',
11+
'Z3'
12+
];
13+
14+
constructor() {
15+
}
16+
}

0 commit comments

Comments
 (0)