티스토리 뷰
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를 사용하지 마라는..
'웹개발 > Angular' 카테고리의 다른 글
[Angular] 05. 컴포넌트 통신과 폼 처리하기 (436) | 2018.09.08 |
---|---|
[Angular] 04. 바인딩, 옵저버블, 파이프 (0) | 2018.08.26 |
[Angular] 03. 의존성 주입 (0) | 2018.08.26 |
[Angular] 02. 라우터로 내비게이션 구현하기 (0) | 2018.08.14 |
[Angular] 01. Angular 시작하기 (0) | 2018.08.13 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Facebook AccountKit
- 웹 소켓 프로토콜
- 한영 변환
- git merge
- Angular CLI
- 번들링
- jQuery
- Gulp
- Angular
- angular2
- Typescript 패키지
- module exports
- paralles desktop
- 의존성 주입
- 폼 유효성 검사
- NgForm
- git branch
- npm
- 아이오닉
- Routes
- password validation
- phone number
- Grunt
- git commit
- Webpack
- 아이오닉2
- ionic2
- typeScript
- End-to-End testing
- 옵저버블
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함