Skip to content

Instantly share code, notes, and snippets.

@gneutzling
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gneutzling/10750336 to your computer and use it in GitHub Desktop.
Save gneutzling/10750336 to your computer and use it in GitHub Desktop.
search directive
<div class="search">
<div class="search__field" data-ng-class="{opened: isOpened}">
<input type="text" id="{{name}}" name="{{name}}" placeholder="{{placeholder}}" ng-model="ngModel">
</div>
<label for="{{name}}" sb-tap="toggle()">
<span class="icon icon-search"></span>
</label>
</div>
.directive('search', function () {
return {
restrict: 'EA',
scope: {
ngModel: '=ngModel',
name: '@name',
placeholder: '@placeholder'
},
templateUrl: 'search.tpl.html',
link: function (scope, elem, attr) {
scope.init = function () {
scope.setup();
scope.isOpened = false;
};
scope.toggle = function () {
scope.isOpened = !scope.isOpened;
};
scope.init();
}
}
})
<search ng-model="keyword" name="temp" placeholder="{{ 'Search' | translate }}"></search>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment