-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
typeahead doesn't work with [formControl] #1595
Comments
it should be possible https://github.com/valor-software/ng2-bootstrap/blob/development/src/typeahead/typeahead.directive.ts#L23 |
I'm sure. I just confirmed it by creating a fresh angular-cli project. Installed bootstrap and ng2-bootstrap. app.module.ts:import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { TypeaheadModule } from 'ng2-bootstrap/typeahead';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
ReactiveFormsModule,
HttpModule,
TypeaheadModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { } app.component.tsimport { Component } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
public myControl: FormControl = new FormControl();
public myForm: FormGroup = new FormGroup({ 'myControl': this.myControl });
public myOptions: string[] = ['a', 'b', 'c'];
} app.component.html<div>
<input [formControl]="myControl" [typeahead]="myOptions" typeaheadOptionsLimit="7" typeaheadMinLength="0" placeholder="Typeahead inside a form"
class="form-control">
</div>
<!--<form [formGroup]="myForm">
<input formControlName="myControl" [typeahead]="myOptions" typeaheadOptionsLimit="7" typeaheadMinLength="0" placeholder="Typeahead inside a form"
class="form-control">
</form>--> This gives the error: Is that line of yours missing the |
please try v1.3.3 |
Fixed. Thank you very much! |
When using reactive forms, it is possible to bind typeahead's value to a formGroup's control with
formControlName
attribute, but not to a standalone control with[formControl]
attribute. If you attempt to set[formControl]
attribute you get an error:The text was updated successfully, but these errors were encountered: