Giter Club home page Giter Club logo

angular-io-datepicker's Introduction

angular-io-datePicker

Customizable DatePicker component for Angular 2.

Motivation

Existing DatePickers do not work as they should... So we have written another one ๐Ÿ˜

Installation

npm i angular-io-datepicker --save

Code Example

You'll need to add DatePickerModule and OverlayModule to your application module. There is has to be FormsModule. If you use Model-Driven Form you'll need to add ReactiveFormModule too.

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    FormsModule,
    ReactiveFormModule,
    OverlayModule,
    DatePickerModule,
    ...
  ],
  providers: [],
  bootstrap: [AppComponent]
})

export class AppModule {
}
Template-Driven Form

Simply add date-picker element with options to your form:

<form #form="ngForm">
    <date-picker ngModel name="date"></date-picker>
</form>
Model-Driven Form

You'll need to add form initialization to your app-component at first:

import { Component } from '@angular/core';
import { FormGroup, FormBuilder } from "@angular/forms";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})
export class AppComponent {
  form: FormGroup;

  constructor(private fb: FormBuilder) {}

  ngOnInit() {
    this.form = this.fb.group({
      date: ''
    });
  }
}

And then add date-picker element to your form:

<form [formGroup]="form">
    <date-picker formControlName="date"></date-picker>
</form>

API Reference

Options can be passed to an element via html attributes:

Property Type Default Description
mode string date Changes view mode - date, datetime, time
disabled boolean false Disables controls
showClearButton boolean true Show or not clear input button
format string defaultFormat = {"date": "LL","datetime": "LLL","time": "LT"}; Changes view format that provides moment

License

This project is licensed under the MIT license. See the LICENSE file for more info.

angular-io-datepicker's People

Contributors

eugenesaenko avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.