Sorry, but you either have no stories or none are selected somehow.
If the problem persists, check the browser console, or the terminal you've run Storybook from.
The component failed to render properly, likely due to a configuration issue in Storybook. Here are some common causes and how you can address them:
This is a pre-release version and is not production ready. For new and ongoing projects, please refer to the latest Design System version.
A component to display a list of suggestions following what the user is typing.
Make sure the @ng-bootstrap/ng-bootstrap
package is already present in your project
or follow ng-bootstrap installation guidelines.
To import all ng-bootstrap components:
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; @NgModule({ imports: [NgbModule], }) export class YourAppModule { }
To import only this component:
import {NgbTypeaheadModule} from '@ng-bootstrap/ng-bootstrap'; @NgModule({ imports: [NgbTypeaheadModule], }) export class YourAppModule { }
A typeahead example that gets values from a static
string[]
debounceTime
operator
<div class="form-control-wrapper form-floating mb-16"> <input id="typeahead-basic" placeholder=" " type="text" class="form-control form-control-lg" [(ngModel)]="model" [ngbTypeahead]="search" /> <label for="typeahead-basic" class="form-label">Search for a US state</label> </div> <hr /> <pre>Model: {{ model | json }}</pre>
import { Component } from '@angular/core'; import { NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap'; import { Observable, OperatorFunction } from 'rxjs'; import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators'; import { FormsModule } from '@angular/forms'; import { JsonPipe } from '@angular/common'; const states = [ 'Alabama', 'Alaska', 'American Samoa', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'District Of Columbia', 'Federated States Of Micronesia', 'Florida', 'Georgia', 'Guam', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Marshall Islands', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Northern Mariana Islands', 'Ohio', 'Oklahoma', 'Oregon', 'Palau', 'Pennsylvania', 'Puerto Rico', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virgin Islands', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming', ]; @Component({ selector: 'ngbd-typeahead-basic', standalone: true, imports: [NgbTypeaheadModule, FormsModule, JsonPipe], templateUrl: './typeahead-basic.html', styles: `.form-control { width: 300px; }`, }) export class NgbdTypeaheadBasic { model: any; search: OperatorFunction<string, readonly string[]> = (text$: Observable<string>) => text$.pipe( debounceTime(200), distinctUntilChanged(), map(term => term.length < 2 ? [] : states.filter(v => v.toLowerCase().indexOf(term.toLowerCase()) > -1).slice(0, 10), ), ); }