change lot of stuff
This commit is contained in:
28
js/directive/search.js
Normal file
28
js/directive/search.js
Normal file
@@ -0,0 +1,28 @@
|
||||
app.directive('search', function ($document, $location) {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
'onSearch': '='
|
||||
},
|
||||
link: function (scope) {
|
||||
var box = $('#searchbox');
|
||||
box.val($location.search().search);
|
||||
|
||||
var doSearch = function() {
|
||||
var value = box.val();
|
||||
scope.$apply(function () {
|
||||
scope.onSearch(value);
|
||||
});
|
||||
}
|
||||
|
||||
box.on('search keyup', function (event) {
|
||||
if (event.type === 'search' || event.keyCode === 13 ) {
|
||||
doSearch();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user