Skip to content

Instantly share code, notes, and snippets.

@gneutzling gneutzling/searchDirective
Last active Aug 29, 2015

What would you like to do?
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">
<label for="{{name}}" sb-tap="toggle()">
<span class="icon icon-search"></span>
.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.isOpened = false;
scope.toggle = function () {
scope.isOpened = !scope.isOpened;
<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
You can’t perform that action at this time.