티스토리 뷰

웹개발/Angular

angular2에서 jquery 사용하기

신수동이 2017. 7. 17. 22:59

angular2에서 jquery 사용하기

참고 : https://stackoverflow.com/questions/30623825/how-to-use-jquery-with-angular2

STEP 1 - First things first

// In the console
// First install jQuery
npm install --save jquery
// and jQuery Definition
npm install -D @types/jquery


STEP 2 - IMPORT

// Now, within any of the app files (ES2015 style)
import * as $ from 'jquery';
//
$('#elemId').width();

// OR

// CommonJS style - working with "require"
import $ = require('jquery')
//
$('#elemId').width();


#UPDATE - Feb - 2017

Lately, I'm writing code with ES6 instead of typescript and am able to import without * as $ in the import statement. This is what it looks like now:

import $ from 'jquery';
//
$('#elemId').width();



이후 블로그를 검색하다가 찾은 글입니다.  (https://joshuajangblog.wordpress.com/2016/07/23/jquery-vs-angular/)

jquery를 사용하지 않고 angular2 기능을 사용하여 대부분 구현가능하기 때문에 

결론은 angular2에서 jquery를 사용하지 마라는.. 


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함