Closed bryanpyle closed 8 years ago
you could just import the type like you do with 'Component' and than use something like ->
import { Pikaday } from 'picaday'
/and then maybe in the constructor of the class add your references. * From documentation of the linke provided * / var picker = new Pikaday({ field: document.getElementById('datepicker'), format: 'D MMM YYYY', onSelect: function() { console.log(this.getMoment().format('Do MMMM YYYY')); } });
above is not tested by me. and i guess you should add something like input binding or something for the element you bind to the 'field'.
Hope this helps you a bit
did the above solution work?
The above solution did not work. The issue is that the cli is not staying up to date with typings. In the readme, it says it is using typings v1.0.0 or greater. But the package.json shows it's using typings v0.8.1. There was a pretty important change between these two versions: v1.0.0 uses the keyword global
in it's typings.json. v0.8.1 uses ambient
instead. So everytime I use typings install, it references it incorrectly. I have tried different combinations of the typings cli and typings dependency, but I can't get it to work on the Ang-cli. I gave up and just started using the quickstart guide. The Quickstart Repo has updated its package.json to the most recent versions of all dependencies. It is a little more tedious to set up, but it is working for me so far. Also look into Module Resolution on TypeScripts website.
You could try the 'tsd' instead of 'typings' ?
Met vriendelijke groet,
Mark Struik
Op 19 jul. 2016 om 19:12 heeft bpyle0092 notifications@github.com het volgende geschreven:
The above solution did not work. The issue is that the cli is not staying up to date with typings. In the readme, it says it is using typings v1.0.0 or greater. But the package.json shows it's using typings v0.8.1. There was a pretty important change between these two versions: v1.0.0 uses the keyword global in it's typings.json. v0.8.1 uses ambient instead. So everytime I use typings install, it references it incorrectly. I have tried different combinations of the typings cli and typings dependency, but I can't get it to work on the Ang-cli. I gave up and just started using the quickstart guide. The Quickstart Repo has updated its package.json to the most recent versions of all dependencies. It is a little more tedious to set up, but it is working for me so far. Also look into Module Resolution on TypeScripts website.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
What I did is, I added the pikaday module in angular-cli.build file, system-config file and gave the path of the module in index.html file (explicitly including the css paths in the html file). Once you have these things in place, you can globally use the pikaday module.
@saransh94 Do you have a gist or example repo? Did you actually get it to work? I would like to see it.
@bpyle0092 The project I'm working on is confidential. But I can definitely assist you on your project, just do the above steps and let me know. I'll take a look at it and will modify it if needed.
I really appreciate the help. But part of the issue I'm having is how exactly to add the modules to certain files. Could you be more specific? For example:
"In angular-cli.build file in vendorNpmFiles
add pikaday/**/*.+(js|js.map)
"
And then to use globally do I just import 'pikaday';
?
Closed as issue was made obsolete by #1455. You should be able to just import it on the next release, and get typings out of @types/*
.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
OSX El Capitan angular-cli: 1.0.0-beta.8 node: 6.2.2 os: darwin x64
Pikaday is a simple datepicker that uses only JavaScript and CSS. No other dependencies are necessary. The import process seems nearly identical to the tutorial for Underscore.
Here is my repo
I created my project using the angular-cli and added a single component called PikadayComponent then made sure it was connected properly to app.component.
I followed the steps from the underscore tutorial for both pikaday and underscore:
1. Install pikaday via npm
npm install pikaday --save
npm install underscore --save
1a. Install typings for library
typings install dt~pikaday --global --save
typings install dt~underscore --global --save
2. Add pikaday to angular-cli-build.js file to vendorNpmFiles array
3. Configure SystemJS mappings to know where to look for pikaday
4. Importing and using underscore library in your project source files
When looking at underscore's
index.d.ts
file, the very bottom exports_
. So I figured the exported variable is what I should use in thedeclare var
statement. The export at the bottom of pikaday'sindex.d.ts
file wasPikaday
, so that's what I used:declare var Pikaday;
Problem When I
ng serve
the project I get the following error report:Nothing is printed in the console.
Another Question For pikaday, It seems that I must declare it with the
field
property set to an input element. See Here. Given that underscore is declared likedeclare var _;
how would I includefield
fordeclare var Pikaday
?Any help or insight would be great.