@@ -19,15 +19,22 @@ const storeManager = provideStore({ currentSearch: SearchReducer });
19
19
<h1>{{title}}</h1>
20
20
<div class="row col-md-8">
21
21
<search-box [store]="store"></search-box>
22
- <proximity-selector [store]="store"></proximity-selector>
22
+ <proximity-selector [store]="store" [disabled]="disableSearch"
23
+ [ngClass]="{ disabled: disableSearch }"></proximity-selector>
24
+ </div>
25
+ <div class="row col-md-8 alert alert-danger" *ngIf="disableSearch">
26
+ <p>Can't use geolocalization with an empty searchbox</p>
23
27
</div>
24
28
<div class="row col-md-8">
25
29
<p>
26
30
Try to type something in the searchbox, play with the location and with radius: the above state will
27
31
always be consistent and up to date.
28
32
</p>
29
- <p>{{ state | json }}</p>
33
+ <p class="state">{{ state | json }}</p>
34
+ <p class="state" *ngIf="disableSearch">{ }</p>
30
35
</div>
36
+ <h2 *ngIf="!disableSearch">Search results:</h2>
37
+ <h2 *ngIf="disableSearch || searchResults.length == 0">No results</h2>
31
38
<div class="row col-md-8">
32
39
<div *ngFor="let result of searchResults" class="thumbnail col-sm-6 col-md-4">
33
40
<div class="caption">
@@ -45,9 +52,9 @@ export class AppComponent implements OnInit {
45
52
title = 'One Source of Truth for Angular 2' ;
46
53
47
54
private state : CurrentSearch ;
48
-
49
55
private currentSearch : Observable < CurrentSearch > ;
50
56
private searchResults : SearchResult [ ] = [ ] ;
57
+ private disableSearch = false ;
51
58
52
59
constructor (
53
60
private store : Store < CurrentSearch > ,
@@ -61,8 +68,10 @@ export class AppComponent implements OnInit {
61
68
this . currentSearch . subscribe ( ( state : CurrentSearch ) => {
62
69
this . state = state ;
63
70
if ( state && state . name && state . name . length > 0 ) {
71
+ this . disableSearch = false ;
64
72
this . youtube . search ( state )
65
73
} else {
74
+ this . disableSearch = true ;
66
75
this . searchResults = [ ] ;
67
76
}
68
77
} ) ;
0 commit comments