🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@seges/angular-ng-intervalpicker

Package Overview
Dependencies
Maintainers
4
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@seges/angular-ng-intervalpicker

Typescript: ">=2.7.2 <2.8.0"

latest
npmnpm
Version
2.0.0
Version published
Weekly downloads
12
50%
Maintainers
4
Weekly downloads
 
Created
Source

SegesIntervalPickerNg

Prerequisites

Typescript: ">=2.7.2 <2.8.0"

Install of peerDependencies in consuming project

npm install rxjs@6.2.0 ng2-date-picker@2.6.2 moment-es6@1.0.0 --save

How to use

app.component.html example

<div class="content">
  <button md-raised-button class="seges-action-button" (click)="onPickIntervalClicked()" value="Vælg dato">
    {{ startDate | date }}
      <span *ngIf="startDate < endDate">- {{ endDate | date }}</span>
  </button>
</div>

app.component.ts example

import { Component } from '@angular/core';
import { MatDialogRef, MatDialog } from '@angular/material';
import { IntervalPickerComponent, IntervalPickerTranslations } from '@seges/angular-ng-intervalpicker';
import moment from 'moment-es6';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';
  startDate: Date = new Date(new Date().setDate(new Date().getDate() - 14));
  endDate: Date = new Date(new Date().getFullYear() + 1, 0, 1);
  translations: IntervalPickerTranslations;
  private intervalPickerModalRef: MatDialogRef<any>;

  constructor(
    private mdDialog: MatDialog
  ) {
    this.translations = {
      day: 'day',
      last: 'last',
      current: 'current',
      next: 'next',
      week: 'week',
      month: 'month',
      year: 'year',
      custom: 'custom',
      past7Days: 'past7Days',
      past14Days: 'past14Days',
      past30Days: 'past30Days',
      from: 'from',
      to: 'to',
      singleDate: 'singleDate',
      ok: 'ok',
      cancel: 'cancel'
    }
  }

  // event handlers
  onPickIntervalClicked() {
    this.intervalPickerModalRef = this.mdDialog.open(IntervalPickerComponent, {
      data: {
        startDate: this.startDate,
        endDate: this.endDate,
        translations: this.translations
      }
    });
    this.intervalPickerModalRef.componentInstance.dialogRef = this.intervalPickerModalRef;
    this.intervalPickerModalRef.disableClose = true;

    this.intervalPickerModalRef.afterClosed().subscribe(result => {
      // check if dates has actually been changed
      if (
        !moment(this.startDate).isSame(moment(result.startDate), 'day')
        || !moment(this.endDate).isSame(moment(result.endDate), 'day')
      ) {
        this.startDate = result.startDate;
        this.endDate = result.endDate;
      }
    });
  }
}

app.module.ts example

import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { IntervalPickerModule } from '@seges/angular-ng-intervalpicker';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    IntervalPickerModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Build and public this module to NPM

Run this command in root directory to build NPM ready code in dist directory

npm run packagr

Change to dist directory

cd dist

Create NPM packaga

npm pack

Upload to NPM from dist directory

npm publish

FAQs

Package last updated on 06 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts