Skip to content

Instantly share code, notes, and snippets.

View harishkotra's full-sized avatar
🏠
Working from home

Harish Kotra harishkotra

🏠
Working from home
View GitHub Profile
@harishkotra
harishkotra / search-in-action-bar.js
Created March 19, 2017 04:39
Ionic 1: Directive to add search bar in the Nav/Action bar of the app
.directive('searchBar', [function () {
return {
scope: {
ngModel: '='
},
require: ['^ionNavBar', '?ngModel'],
restrict: 'E',
replace: true,
template: '<ion-nav-buttons side="right">'+
'<div class="searchBar item-input-inset">'+
@harishkotra
harishkotra / gist:89a5f00f830ac3aefe1103ab8b8884e1
Created March 19, 2017 04:35
Ionic 1 directive to disable special characters in an input field
.directive('noSpecialChar', function() {
return {
require: 'ngModel',
restrict: 'A',
link: function(scope, element, attrs, modelCtrl) {
modelCtrl.$parsers.push(function(inputValue) {
if (inputValue == null)
return ''
cleanInputValue = inputValue.replace(/[^\w\s]/gi, '');
if (cleanInputValue != inputValue) {