|
@@ -1,13 +1,47 @@
|
1
|
1
|
import { Component } from '@angular/core';
|
2
|
2
|
import { NavController } from 'ionic-angular';
|
|
3
|
+import { ConnectionProvider } from './../../providers/connection/connection';
|
|
4
|
+import { DistrictProvider } from './../../providers/connection/district';
|
|
5
|
+
|
|
6
|
+
|
3
|
7
|
|
4
|
8
|
@Component({
|
5
|
9
|
selector: 'page-search',
|
6
|
10
|
templateUrl: 'search.html'
|
7
|
11
|
})
|
8
|
12
|
export class SearchPage {
|
|
13
|
+ listOfSchools: any;
|
|
14
|
+ filterSchools: any;
|
9
|
15
|
|
10
|
|
- constructor(public navCtrl: NavController) {
|
|
16
|
+ constructor(public navCtrl: NavController, public conn: ConnectionProvider, public dist: DistrictProvider) {
|
11
|
17
|
}
|
|
18
|
+ ngOnInit(): void {
|
|
19
|
+ //Called after the constructor, initializing input properties, and the first call to ngOnChanges.
|
|
20
|
+ //Add 'implements OnInit' to the class.
|
|
21
|
+ this.dist.getAllSchools().subscribe(data => this.setData(data))
|
|
22
|
+ }
|
|
23
|
+
|
|
24
|
+ setData(data: any) {
|
|
25
|
+ this.listOfSchools = this.dist.parseData(data);
|
|
26
|
+ this.filterSchools = this.listOfSchools;
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ getSchool(event: any) {
|
|
30
|
+ this.filterSchools = this.listOfSchools
|
|
31
|
+ let val = event.target.value;
|
|
32
|
+
|
|
33
|
+ if (val && val.trim() != '') {
|
|
34
|
+ this.filterSchools = this.filterSchools.filter((item) => {
|
|
35
|
+ return (item.name.toLowerCase().indexOf(val.toLowerCase()) > -1);
|
|
36
|
+ });
|
|
37
|
+ }
|
|
38
|
+
|
|
39
|
+ }
|
|
40
|
+}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
12
|
47
|
|
13
|
|
-}
|