GithubHelp home page GithubHelp logo

gillardo / ngx-bootstrap-datetime-popup Goto Github PK

View Code? Open in Web Editor NEW
31.0 4.0 13.0 5.69 MB

Date and time picker using ngx-bootstrap library

License: MIT License

TypeScript 68.44% JavaScript 11.56% HTML 19.68% SCSS 0.32%

ngx-bootstrap-datetime-popup's Introduction

NOTE: DO NOT USE 5.0.0 THIS IS BROKEN!! PLEASE USE 5.0.1+ WITH NGX-BOOTSTRAP 5.0.0+. If you require ngx-bootstrap v4+ then continue to use 4.3.0+. For angular 10, please use 6.0.0+

ngx-bootstrap-datetime-popup

Date and time popup picker using ngx-bootstrap library

This is currently a very simple date time picker, with only the features i needed for a project that i use this in. Happy to add more features

image image image

Simple example in demo folder, which can also be found on github pages at https://gillardo.github.io/ngx-bootstrap-datetime-popup/

To use the component, import the DatetimePopupModule via your .ts code, and add it to your modules using the .forRoot() function. You must also import the modules datepicker, timepicker and dropdown from ngx-bootstrap as there are services that are used

import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { DatepickerModule } from 'ngx-bootstrap/datepicker';
import { TimepickerModule } from 'ngx-bootstrap/timepicker';
import { DatetimePopupModule } from 'ngx-bootstrap-datetime-popup';

import { AppComponent } from './app.component';

@NgModule({
  imports: [
    FormsModule,
    BrowserModule,
    BrowserAnimationsModule,
    BsDropdownModule.forRoot(),
    DatepickerModule.forRoot(),
    TimepickerModule.forRoot(),
    DatetimePopupModule.forRoot()
  ],
  declarations: [ AppComponent ],
  bootstrap: [ AppComponent ]
})
export class AppModule {
  
}

Now add the component to your HTML.

<datetime-popup [(value)]="myDate"></datetime-popup>

I have now added code which allows you to change attributes on the "Clear", "Now" and "Close" buttons. in order to do this, you must use an object that implements the same properties as the IDatetimePopupButtonOptions interface

export interface IDatetimePopupButtonOptions {
    // should the button be shown
    show: boolean;

    // What text label should it be given
    label: string;

    // css classes to be used, default is 'btn btn-sm btn-secondary'
    cssClass: string;
}

The component accepts 3 inputs closeButton, clearButton and nowButton, so you can bind your options like so:

<datetime-popup [(value)]="myDate" [closeButton]="myCloseOptions"></datetime-popup>

Since i dont really like the style of the ngx-bootstrap datePicker, you can override the css like any other style, here is an example

This css also overrides the glyphicon icons that are no longer used in bootstrap 4.

datetime-popup.dropdown .glyphicon {
    display: inline-block;
    font: normal normal normal 14px/1 FontAwesome;
    font-size: inherit;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

datetime-popup.dropdown timepicker {
    display: flex;
    justify-content: center;
}

datetime-popup.dropdown .bg-faded {
    border:0;
    background-color: #fff;
}

datetime-popup.dropdown datepicker button {
    border:0;
    background-color: #fff;
}

datetime-popup.dropdown datepicker button.active {
    background-color: #ddd;
}

datetime-popup.dropdown .glyphicon.glyphicon-remove-circle:before {
    content: "\f05c";
}

datetime-popup.dropdown .glyphicon.glyphicon-chevron-down:before {
    content: "\f078";
}

datetime-popup.dropdown .glyphicon.glyphicon-chevron-up:before {
    content: "\f077";
}

datetime-popup.dropdown .glyphicon.glyphicon-chevron-left:before {
    content: "\f053";
}

datetime-popup.dropdown .glyphicon.glyphicon-chevron-right:before {
    content: "\f054";
}

datetime-popup.dropdown .glyphicon.hidden {
    display: none !important;
}

###Common Error If you get an error similar to this, then it because you have got a different version of ngx-bootstrap installed than this component is using. If you open the ngx-bootstrap-datetime-popup and see a node_modules folder you will probably see a folder called ngx-bootstrap inside it.

ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[BsDropdownDirective -> ComponentLoaderFactory]:
StaticInjectorError(Platform: core)[BsDropdownDirective -> ComponentLoaderFactory]:
NullInjectorError: No provider for ComponentLoaderFactory!
Error: NullInjectorError: No provider for ComponentLoaderFactory!

If you want more features please create a PR as I am a little struck for time at the moment. Happy coding!

ngx-bootstrap-datetime-popup's People

Contributors

dependabot[bot] avatar gillardo avatar jethas-bennettjones avatar sn123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ngx-bootstrap-datetime-popup's Issues

New feature: Support showMeridian

Hi

I have been looking for a component which combines a datepicker and a timepicker in a nice way, and yours look really good.

It seems the timepicker has a flag that can be used to enable/disable the Meridian

<timepicker [(ngModel)]="mytime" [showMeridian]="ismeridian"></timepicker>

It would be cool to be able to pass that setting out through your component.

Best regards

ERROR in node_modules/ngx-bootstrap-datetime-popup/node_modules/@angular/core/core.d.ts(7414,55): error TS1005: ']' expected. node_modules/ngx-bootstrap-datetime-popup/node_modules/@angular/core/core.d.ts(7414,57): error TS1134: Variable declaration expected. node_modules/ngx-bootstrap-datetime-popup/node_modules/@angular/core/core.d.ts(7414,116): error TS1005: ';' expected.

Hello all, I am getting this error when I installed an run it. Please help me out.

"ngx-bootstrap": "^2.0.5",
"ngx-bootstrap-datetime-popup": "^6.0.0", 
Angular CLI: 7.3.10

Issue with contents of npm package for v7.0.0

Hi @Gillardo,

Thanks for pushing out v7. I noticed, though, that the contents is of the main folder and not of the dist folder, which is what I was expecting. Would you be able to republish this, but with the contents of the dist folder only?

Not showing popup only.

Hi! Gillardo, I have implemented this ngx-bootstrap-datetime-popup, according to the documentation but it's now showing up. However, the when I inspect the elements its show ng-reflect-show-popup= true
Can you please help me with this?

Peer Dependency Issue

Package "ngx-bootstrap-datetime-popup" has an incompatible peer dependency to "@angular/forms" (requires "^4.0.0" (extended), would install "7.2.1").

ERROR in DatetimePopupModule is not an NgModule

When performing the build process or serve the component is returning that message.
Versions:

@angular/cli: 1.2.6
node: 8.1.4
os: linux x64
@angular/animations: 4.3.4
@angular/common: 4.3.4
@angular/compiler: 4.3.4
@angular/core: 4.3.4
@angular/forms: 4.3.4
@angular/http: 4.3.4
@angular/platform-browser: 4.3.4
@angular/platform-browser-dynamic: 4.3.4
@angular/platform-server: 4.3.4
@angular/router: 4.3.4
@angular/service-worker: 1.0.0-beta.16
@angular/cdk: 2.0.0-beta.8
@angular/cli: 1.2.6
@angular/compiler-cli: 4.3.4

No provider for ComponentLoaderFactory

Hello,
Error: StaticInjectorError(AppModule)[BsDropdownDirective -> ComponentLoaderFactory]:
StaticInjectorError(Platform: core)[BsDropdownDirective -> ComponentLoaderFactory]:
NullInjectorError: No provider for ComponentLoaderFactory!

I have main appModule with import childModule. In childModule:
import { DatetimePopupModule } from 'ngx-bootstrap-datetime-popup';
imports: [... , DatetimePopupModule, ...]

I see you removed ".forRoot()", what needs to be done now?

Is it compatible with Reactive Forms?

I'm developing an application but I'm facing problems when using this with reactive forms. The following exception is thrown when I bind my formControlName to the <datetime-popup> : No value accessor for form control with name
I have dug into your code and haven't seen anything related to reactive forms.

About Past date

Hello,

I am using this ngx-bootstrap-datetime-popup
and its working fine in my website
but i want to hide the past date so any one can help to me that how to hide past date.
Is datetime Popup provide any option to hide past date ?
my code

<datetime-popup [value]="loanDate" [minDa] (valueChange)="onValueChange($event)" [(showPopup)]="showPicker" [showDate]="showDate" [showTime]="showTime" [closeButton]="myCloseOptions">

showTime

Thank you very much for providing this. I have a quick question. When I saw showDate=true and showTime=false it does not seem to show the calendar at all. If I hide the date and show the time it does show the time. Am I doing something wrong?

Again, thank you!

Plunker demo

Hi!

The Plunker demo linked in Readme.md doesn't work, throws a bunch of 404 in the console.

No provider for ComponentLoaderFactory

Hello,
I have the same problem that #19 but, i'm using [email protected] and [email protected].

ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[BsDropdownDirective -> ComponentLoaderFactory]:
StaticInjectorError(Platform: core)[BsDropdownDirective -> ComponentLoaderFactory]:
NullInjectorError: No provider for ComponentLoaderFactory!
Error: NullInjectorError: No provider for ComponentLoaderFactory!

My app.module :
@NgModule({
imports: [
BrowserAnimationsModule,
BrowserModule,
CoreModule,
SharedModule,

    AppRoutingModule,

    BsDropdownModule.forRoot(),
    DatepickerModule.forRoot(),
    TimepickerModule.forRoot(),
    DatetimePopupModule.forRoot()
],

...})

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.