|
10 | 10 | angular.module('yoAngularCordovaApp')
|
11 | 11 | .controller('GlobalCtrl', function ($scope, $rootScope, $mdSidenav, $mdToast){
|
12 | 12 |
|
13 |
| - $scope.searchActive = false; |
| 13 | + $scope.searchModel = { |
| 14 | + searchActive: false, |
| 15 | + searchQuery: null |
| 16 | + }; |
14 | 17 |
|
15 | 18 | $scope.clickNav = function() {
|
16 | 19 | // Publish an event that can be handled by directives
|
@@ -48,10 +51,19 @@ angular.module('yoAngularCordovaApp')
|
48 | 51 | });
|
49 | 52 | };
|
50 | 53 |
|
| 54 | + $scope.executeSearch = function() { |
| 55 | + var path = '/search/' + $scope.searchModel.searchQuery; |
| 56 | + console.debug('go to path ' + path); |
| 57 | + $scope.disableSearch(); |
| 58 | + // lose focus on search bar |
| 59 | + $rootScope.go(path); |
| 60 | + }; |
| 61 | + |
51 | 62 | $scope.disableSearch = function() {
|
52 | 63 | //var searchBox = angular.element('#searchBox');
|
53 | 64 | //searchBox.blur();
|
54 |
| - $scope.searchActive = false; |
| 65 | + $scope.searchModel.searchActive = false; |
| 66 | + $scope.searchModel.searchQuery = null; |
55 | 67 | };
|
56 | 68 |
|
57 | 69 | /**
|
@@ -93,7 +105,15 @@ angular.module('yoAngularCordovaApp')
|
93 | 105 | $scope.showSearch = function() {
|
94 | 106 | //var searchBox = angular.element('#searchBox');
|
95 | 107 | //searchBox.focus();
|
96 |
| - $scope.searchActive = true; |
| 108 | + $scope.searchModel.searchActive = true; |
| 109 | + }; |
| 110 | + |
| 111 | + $scope.toggleSearch = function() { |
| 112 | + if ($scope.searchModel.searchActive) { |
| 113 | + $scope.disableSearch(); |
| 114 | + } else { |
| 115 | + $scope.showSearch(); |
| 116 | + } |
97 | 117 | };
|
98 | 118 |
|
99 | 119 | /**
|
|
0 commit comments