티스토리 뷰
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
- 한영 변환
- Typescript 패키지
- typeScript
- Angular CLI
- 폼 유효성 검사
- ionic2
- 옵저버블
- 아이오닉2
- 아이오닉
- jQuery
- phone number
- paralles desktop
- git branch
- module exports
- Gulp
- password validation
- git commit
- Angular
- Facebook AccountKit
- Routes
- NgForm
- Grunt
- End-to-End testing
- 웹 소켓 프로토콜
- angular2
- 번들링
- Webpack
- git merge
- npm
- 의존성 주입
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함