Gbuomprisco / ng2-material-select

Angular 2 Material-like Select Component
35 stars 14 forks source link

Angular Material Select Component

A component inspired by material design for creating visually nice select components.

Demo

Checkout a live demo at http://www.buompris.co/ng2-material-select

Install

npm install ng2-material-select --save

API

Example

<ng2-select [placeholder]="'Choose your framework'"
            [options]="options"
            [(ngModel)]="framework">

</ng2-select>
// import module
import { Ng2SelectModule } from 'ng2-material-select';

@NgModule({
    imports: [ Ng2SelectModule ]
    // ..
})
export class MyModule {}

Advanced Usage using objects

In case you want to use objects instead of simple arrays, you might want to use 3 further options:

In addition to that you may listen to a change event to get notified whenever a new option has been selected:

Example

<ng2-select [placeholder]="'Choose your framework'"
            [displayBy]="'name'"
            [selectedDisplayBy]="'label'"
            [identifyBy]="'name'"
            [options]="options"
            [(ngModel)]="framework">
</ng2-select>
import { Component } from '@angular/core';

@Component({
    selector: 'app',
    template: require('./home.html')
})

export class App {
    framework = 'Angular 2';
    options = [
        {
            name: 'Angular2',
            label: 'ng2',
            id: 0
        },
        {
            name: 'React',
            label: 'rx',
            id: 1
        }
    ];
}

TODO