Skip to content

Instantly share code, notes, and snippets.

@gneutzling gneutzling/searchDirective
Last active Aug 29, 2015

Embed
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">
</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
You can’t perform that action at this time.