Just getting started with angular 4
I've put together an ngModule package called
mds.angular.bootstrap.datetimepicker
and here's the content of the package.json
{
"name": "mds.angular.bootstrap.datetimepicker",
"version": "0.9.8",
"description": "Persian and gregorian DateTimePicker with angular 4",
"license": "MIT",
"main": "./mds-datetimePicker.module.js",
"types": [
"./mds-datetimePicker.module.d.ts",
"./assests/date.interface.d.ts",
"./assests/day.interface.d.ts",
"./assests/rangeDate.interface.d.ts"
],
"moduleResolution": "node",
"author": {
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3f525b4c604c50594b7f465e575050115c5052">[email protected]</a>",
"name": "Mohammad Dayyan",
"url": "https://github.com/Mds92/mds-angular-bootstrap-datetime-picker"
},
"repository": {
"type": "public",
"url": "https://github.com/Mds92/mds-angular-bootstrap-datetime-picker"
},
"homepage": "https://github.com/Mds92/mds-angular-bootstrap-datetime-picker",
"dependencies": {
"@angular/animations": "^4.1.2",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"jquery": "^3.2.1",
"mds.persian.calendar": "^0.9.69",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
}
}
I've successfully published it on npm
Now I'm looking to use this package in another angular 4 project.
So I've installed the package using
npm install mds.angular.bootstrap.datetimepicker --save
Then I proceed to implement it as follows:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { MdsDatetimePickerModule } from 'mds.angular.bootstrap.datetimepicker';
import { AppComponent } from './app.component';
@NgModule({
declarations: [ AppComponent ],
imports: [
BrowserModule,
FormsModule,
HttpModule,
MdsDatetimePickerModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Things were going smoothly until I had to import IDate
from the
mds.angular.bootstrap.datetimepicker
package for usage within my component.However, upon attempting to do so, an exception was thrown:
ERROR in D:/Sources/sample/src/app/app.component.ts (2,23): Cannot find module 'date.interface'.
import { Component } from '@angular/core';
import { IDate } from 'date.interface'; //ERROR
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'Mds Angular Bootstrap DateTimePicker';
viewInit = false;
inLinePersianDateTimePicker = '';
inlinePersianDatePickerChanged(selectedDate: IDate) {
if (!this.viewInit) return;
this.inLinePersianDateTimePicker = selectedDate.formatString;
}
inLineGregorianDateTimePicker = '';
inlineGregorianDatePickerChanged(selectedDate: IDate) {
if (!this.viewInit) return;
this.inLineGregorianDateTimePicker = selectedDate.formatString;
}
popoverPersianDateTimePicker = '';
popoverPersianDateTimePickerChanged(selectedDate: IDate) {
if (!this.viewInit) return;
this.popoverPersianDateTimePicker = selectedDate.formatString;
}
popoverGregorianDateTimePicker = '';
popoverGregorianDateTimePickerChanged(selectedDate: IDate) {
if (!this.viewInit) return;
this.popoverGregorianDateTimePicker = selectedDate.formatString;
}
ngAfterViewInit() {
this.viewInit = true;
}
}
This is the IDate
interface within the
mds.angular.bootstrap.datetimepicker
package
export interface IDate {
year: number;
month: number;
day: number;
hour: number;
minute: number;
second: number;
millisecond: number;
formatString: string;
}
How can I properly utilize the IDate
interface in external applications?