Przejdź do głównej zawartości

Angular2 + Moment.js library with Visual Studio 2017 .Net Core 2.0

Hey there!
Recently I was facing problem with adding MomentJs library to Angular2 in .net core 2.0 project.
 I'm using Visual Studio 2017 15.3.3.
 (https://www.visualstudio.com/pl/thank-you-downloading-visual-studio/?sku=Community&rel=15)


  1. Create new test project


2. Use Web -> Angular template 

3. Compile and run in chrome to check that everything is ok. 

4. Edit package.json. At the end of "dependencies" add new line: 
"moment": "2.18.1"


5. Edit tsconfig.json file,
At "compilerOptions" add: "allowSyntheticDefaultImports": true,



6. Edit home.component.ts and add:

import * as moment from 'moment';

and the constructor.
    constructor() {
        try {
            console.log("test");
            let now = moment().format('LLLL');
            console.log(now);
        } catch (e) {
            console.log(e);
        }
    }

set breakpoints





and enjoy Moment library! 




Komentarze

Popularne posty z tego bloga

NetBeans and Trackpoint problem...

Netbeans doesn't allow (for some reasons) using native trackpoint + third blue button for scrolling through code view listing :/ that's annoying if You're not using mouse wheel ... I have Lenovo X200 and that was big problem for me... here is solution: open C:\Program Files\Lenovo\TrackPoint find tp4table.dat an edit it in Notepad++, add these lines, between similar lines: ; NetBeans support *,*,netbeans.exe,*,*,*,WheelStd,0,9 save the file, restart computer and voila... now Netbeans supports scrolling with Lenevo's trackpoint... tested with Netbeans 7.01 on win7 and default lenovo's trackpoint drivers

Send WinKey - Open Start Menu...

Send WinKey is tiny application that is emulating click of Windows Key... * You can use it while binding / mapping your hardware keys (ex Xperia, Touch Pro etc.) when You need the "fast" opening of Start menu (not touching screen but pressing the button...) Cab Installation XDA-Developers Thread *(yesssss... I know that MortScript has got that kind of options... but ... not everybody needs to have mortscript installed... or not everybody wants to edit those lines of scripts/codes... etc) :) cheers...