Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding formControl as a component argument #758

Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"typescript": "2.1.5",
"wallaby-webpack": "0.0.30",
"webdriver-manager": "11.1.1",
"zone.js": "0.7.5"

This comment was marked as off-topic.

"zone.js": "0.7.6"
},
"contributors": [
{
Expand Down
3 changes: 2 additions & 1 deletion src/select/select.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule } from '@angular/forms';

import { SelectComponent } from './select';
import { HighlightPipe } from './select-pipes';
import { OffClickDirective } from './off-click';

@NgModule({
imports: [CommonModule],
imports: [CommonModule, ReactiveFormsModule],
declarations: [SelectComponent, HighlightPipe, OffClickDirective],
exports: [SelectComponent, HighlightPipe, OffClickDirective]
})
Expand Down
10 changes: 7 additions & 3 deletions src/select/select.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, Output, EventEmitter, ElementRef, OnInit, forwardRef } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { ControlValueAccessor, NG_VALUE_ACCESSOR, FormControl } from '@angular/forms';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { SelectItem } from './select-item';
import { stripTags } from './select-pipes';
Expand Down Expand Up @@ -143,9 +143,9 @@ let styles = `
</span>
</div>
<input type="text" autocomplete="false" tabindex="-1"
[formControl]="formControl"
(keydown)="inputEvent($event)"
(keyup)="inputEvent($event, true)"
[disabled]="disabled"
class="form-control ui-select-search"
*ngIf="inputMode"
placeholder="{{active.length <= 0 ? placeholder : ''}}">
Expand Down Expand Up @@ -205,10 +205,10 @@ let styles = `
</span>
</span>
<input type="text"
[formControl]="formControl"
(keydown)="inputEvent($event)"
(keyup)="inputEvent($event, true)"
(click)="matchClick($event)"
[disabled]="disabled"
autocomplete="false"
autocorrect="off"
autocapitalize="off"
Expand Down Expand Up @@ -259,6 +259,7 @@ export class SelectComponent implements OnInit, ControlValueAccessor {
@Input() public textField:string = 'text';
@Input() public childrenField:string = 'children';
@Input() public multiple:boolean = false;
@Input() public formControl = new FormControl();

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.


@Input()
public set items(value:Array<any>) {
Expand All @@ -278,7 +279,10 @@ export class SelectComponent implements OnInit, ControlValueAccessor {
public set disabled(value:boolean) {
this._disabled = value;
if (this._disabled === true) {
this.formControl.disable();
this.hideOptions();
} else {
this.formControl.enable();
}
}

Expand Down