gh0st gh0st - 1 month ago 14
Javascript Question

Implementing angular2 component into my project

I'm starting a new project with angular 2 using the angular-cli tool. I've run

ng install -g angular-cli
to install angular-cli. And then I've already run
ng new MyProject
to have angular-cli create the directory structure and files I need to get my new project up and running. Once angular-cli had that all built I changed directories into ~/MyProject and ran
npm install --save angular2-calendar
.

Now I want to use this component in MyProject. I had the impression this would be incredibly easy but either my google foo for finding instruction for angular2 is abysmal, or the documentation for angular2-calendar is.

This is what I've tried so far. After running the
npm install --save angular2-calendar
I went into my
MyProject/src/app/app.component.ts
file and added
import { CalendarModule } from 'angular2-calendar';
. I then went into my corresponding
app.component.html
to add the line
<CalendarModule></CalendarModule>
.

Basically all I want to do is write an angular2 app which uses the angular2-calendar to display data that my users enter into a form I will build.

Am I on the right track here? Am I missing a step I needed to take before running
ng new MyProject
? Is there a clean and clear tutorial on how to do this? Because isn't this a huge feature of angular? Being able to take someone else's module and use it in your project?

Answer

<CalendarModule></CalendarModule> will not work. I went to his demo site at: https://github.com/mattlewis92/angular2-calendar/blob/master/demo/demo.component.ts

and looked at the code for the demo. He shows you what to import and how to set it up. Hope this helps.

Comments