Add autocomplete input option on search control

Refs #69
This commit is contained in:
Will Abson
2016-06-02 09:23:36 +01:00
parent f6964aed77
commit 831bc9eb7d
3 changed files with 9 additions and 1 deletions

View File

@@ -166,6 +166,7 @@ bootstrap(SearchDemo, [
**searchTerm**: {string} (optional) default "". Search term to pre-populate the field with<br />
**inputType**: {string} (optional) default "text". Type of the input field to render, e.g. "search" or "text" (default)<br />
**expandable** {boolean} (optional) default true. Whether to use an expanding search control, if false then a regular input is used.
**autocomplete** {boolean} (optional) default true. Whether the browser should offer field auto-completion for the input field to the user.
### Search results

View File

@@ -4,7 +4,7 @@
<i class="material-icons">search</i>
</label>
<div [class]="getTextFieldHolderClassName()">
<input class="mdl-textfield__input" [type]="inputType" id="searchTerm" [ngFormControl]="searchControl" [(ngModel)]="searchTerm">
<input class="mdl-textfield__input" [type]="inputType" [autocomplete]="getAutoComplete()" id="searchTerm" [ngFormControl]="searchControl" [(ngModel)]="searchTerm">
<label class="mdl-textfield__label" for="searchTerm">Search content</label>
</div>
</div>

View File

@@ -38,6 +38,9 @@ export class AlfrescoSearchControlComponent {
@Input()
inputType = 'text';
@Input()
autocomplete: boolean = true;
@Input()
expandable: boolean = true;
@@ -67,6 +70,10 @@ export class AlfrescoSearchControlComponent {
return this.expandable ? ' mdl-textfield__expandable-holder' : '';
}
getAutoComplete(): string {
return this.autocomplete ? 'on' : 'off';
}
/**
* Method called on form submit, i.e. when the user has hit enter
*