SlideShare uma empresa Scribd logo
1 de 37
Baixar para ler offline
AngularJS Quick Start
NHNENT.
협업시스템개발팀 김정기
2015.10.19
개요
목표
● AngularJS의 기본 개념을 익힌다.
● TodoApp 코드 분석을 통해 동작원리 및 실습 과정을 소개한다.
개요
대상
● jQuery의 기본 사용법을 아시는 분
● AngularJS를 들어 봤거나 기본 기능만 테스트 해보신 분
● 실무에 적용해보고 싶으신 분
기본 개념
Angluar JS를 선택하는 이유
● 자바스크립트 코드량 감소
● 단순 자바스크립트 객체 데이터 모델을 이용한 view model 양방향 바인딩
● 재사용할 수 있는 UI 컴포넌트 개발 및 다양한 오픈소스 활용
Angluar JS를 선택하는 이유
● DI를 이용한 모듈 분리와 테스트의 용이성
● HTML&CSS 마크업과 JS 개발의 분리
● 세계적으로 가장 많이 사용하는 프레임워크
Angluar JS의 특징
● MVW 개발방식
● 양방향 데이터 바인딩
● 지시자를 이용한 컴포넌트화
Angluar JS의 특징
● AngularJS 템플릿
● 의존성 주입
● 테스트 프레임워크
Angluar JS의 특징
● SPA를 위한 라우터
● $q, $timeout 서비스를 이용한 비동기 프로그래밍 지원
Angluar JS의 특징
Angluar JS의 특징
● MVW 개발방식
○ Model View Whatever
Angluar JS의 특징
● MVW 개발방식
○ 구성요소
Angluar JS의 특징
● MVW 개발방식
○ 구성요소 흐름도
Angluar JS의 특징
● 양방향 데이터 바인딩
http://todomvc.com/examples/angularjs/#/
Angluar JS의 특징
● 양방향 데이터 바인딩
angular.module('todomvc')
.controller('TodoCtrl', function TodoCtrl($scope, $routeParams, $filter, store) {
$scope.todos = store.todos;
$scope.newTodo = '';
$scope.editedTodo = null;
…
$scope.addTodo = function () { … };
$scope.editTodo = function (todo) { … };
$scope.saveEdits = function (todo, event) { … };
$scope.revertEdits = function (todo) { … };
$scope.removeTodo = function (todo) { … };
$scope.saveTodo = function (todo) { … };
...
});
Angluar JS의 특징
● 양방향 데이터 바인딩
<section id="main" ng-show="todos.length" ng-cloak>
<input id="toggle-all" type="checkbox" ng-model="allChecked" ng-click="markAll
(allChecked)">
<label for="toggle-all">Mark all as complete</label>
<ul id="todo-list">
<li ng-repeat="todo in todos | filter:statusFilter track by $index">
<div class="view">
<input class="toggle" type="checkbox" ng-model="todo.completed" ng-
change="toggleCompleted(todo)">
<label ng-dblclick="editTodo(todo)">{{todo.title}}</label>
<button class="destroy" ng-click="removeTodo(todo)"></button>
</div>
<form ng-submit="saveEdits(todo, 'submit')">
<input class="edit" ng-trim="false" ng-model="todo.title" todo-escape="
revertEdits(todo)" ng-blur="saveEdits(todo, 'blur')" todo-focus="todo == editedTodo">
</form>
</li>
</ul>
</section>
Angluar JS의 특징
● 양방향 데이터 바인딩
Angluar JS의 특징
● 의존성 주입
Angluar JS의 특징
● 의존성 주입
○ 모듈 의존성
angular.module('todomvc', [
‘ngCookies’,
‘ngRoute’,
‘ui.sortable’
])
.config(function($routeProvider){
…
});
Angluar JS의 특징
● 의존성 주입
angular.module('todomvc')
.controller('TodoCtrl', function TodoCtrl($scope, $routeParams, filter,
store) {
$scope.todos = store.todos;
$scope.newTodo = '';
$scope.editedTodo = null;
…
$scope.addTodo = function () { … };
$scope.editTodo = function (todo) { … };
$scope.saveEdits = function (todo, event) { … };
$scope.revertEdits = function (todo) { … };
$scope.removeTodo = function (todo) { … };
$scope.saveTodo = function (todo) { … };
...
});
Angluar JS의 특징
● AngularJS 템플릿
Angluar JS의 특징
● 지시자 (Directive)
○ 재활용가능한 웹 컴포넌트
Angluar JS의 특징
● 지시자 (Directive)
Angluar JS의 특징
● 지시자 (Directive)
○ 코드로 표현하자면 …
var html = ‘<div ng-bind=”express”></div>”;
//1단계 ) HTML을 DOM으로 변환
var template = angular.element(html);
//2단계) 템플릿 컴파일 하기
var linkFn = $compile(template);
//3단계) 컴파일된 템플릿과 스코프 객체를 연결
var element = linkFn(scope);
//4단계) 부모 DOMㅇP CNRK
parent.appendChild(element);
Angluar JS의 특징
● 테스트 프레임워크
Angluar JS의 특징
● 테스트 프레임워크
○ BDD
■ describe
● it
(function () {
'use strict';
describe('Todo Controller', function () {
var ctrl, scope, store;
// Load the module containing the app, only 'ng' is loaded by default.
beforeEach(module('todomvc'));
beforeEach(inject(function ($controller, $rootScope, localStorage) {
scope = $rootScope.$new();
...
ctrl = $controller('TodoCtrl', {
$scope: scope,
store: store
});
}));
it('should have all Todos completed', function () {
scope.$digest();
expect(scope.allChecked).toBeTruthy();
});
}());
코드 분석
TODO Angluar JS
● 참고 예제
http://todomvc.com/examples/angularjs/#/
https://github.com/tastejs/todomvc/tree/gh-
pages/examples/angularjs
TODO Angluar JS
● 기능 분석
* 할일 등록
* INPUT 입력 후 목록 하단에표시
* TODO + DONE 수정
* 항목 더블 클릭 시 수정 모드
* 할일 목록
* 기본
* All - (TODO + DONE)
* Active - TODO(해야할일만)
* Completed - DONE(완료된일만)
* 상태 변경
* 선택 업무 상태 변경 (TODO <-> DONE)
* 전체 업무 상태 변경 (TODO <-> DONE)
* 완료 업무 삭제
* 항목 DONE 업무 삭제 [X버튼]
* 항목 DONE 업무 삭제 [Clear Completed]
* 전체 DONE 업무 삭제
* 상태 표시
* TODO 개수
* 필터 버튼 표시 [All, Active, Completed]
* Clear Completed
http://todomvc.com/examples/angularjs/#/
https://github.com/tastejs/todomvc/tree/gh-
pages/examples/angularjs
TODO Angluar JS
● 기능 분석
○ 파일 구조
* index.html
* HTML 페이지구성 및 angular template 정의
* app.js
* angular bootstrap 및 라우팅정의
* todoCtrl.js
* 기능별외부 scope function 정의
* todoStorage.js
* todo list 및 item 읽기/저장/수정/삭제 기능 정의 서비스
* todoEscape.js
* keyevent escape 처리 directive
* todoFocus.js
* 해당영역input focus 처리 directivehttp://plnkr.
co/edit/8DmBdPz90gCK3dxdyTqV?
p=preview
TODO Angluar JS
● plnkr.co 로 UI 테스트
○ angular template 전체
http://plnkr.
co/edit/8DmBdPz90gCK3dxdyTqV?
p=preview
TODO Angluar JS
● plnkr.co 로 UI 테스트
○ bootstrap
■ domready event 시 ng-app이
지정된 element를 대상으
로 angular 초기화 실행
■ 모듈 정의
http://plnkr.
co/edit/8DmBdPz90gCK3dxdyTqV?
p=preview
URL Path가 ‘/’ or /#/active or
/#/completed 일때 TodoCtrl과
todomvc-index.html 적용
-> URL Base SPA 기본 작동
app.js
index.html
모듈 정
의
TODO Angluar JS
● plnkr.co 로 UI 테스트
○ Service
■ todoStorage
● todo list
● todo item 읽기/저장/
수정/삭제
http://plnkr.
co/edit/8DmBdPz90gCK3dxdyTqV?
p=preview
todoCtrl.jstodoStorage.js 모듈 사
용
TODO Angluar JS
● plnkr.co 로 UI 테스트
○ Service
■ todoStorage
● todo list
● todo item 읽기/저장/
수정/삭제
http://plnkr.
co/edit/8DmBdPz90gCK3dxdyTqV?
p=preview
todoCtrl.jstodoStorage.js 모듈 사
용
모듈 주
입
모듈 주
입
TODO Angluar JS
● plnkr.co 로 UI 테스트
○ Angular Directive
■ ng-${DIRECITVENAME}
■ ng-repeat, ng-if, ng-show
■ ng-change, ng-click ...
http://plnkr.
co/edit/8DmBdPz90gCK3dxdyTqV?
p=preview
<section id="main" ng-show="todos.length" ng-cloak>
<input id="toggle-all" type="checkbox" ng-model="allChecked" ng-click="markAll
(allChecked)">
<label for="toggle-all">Mark all as complete</label>
<ul id="todo-list">
<li ng-repeat="todo in todos | filter:statusFilter track by $index">
<div class="view">
<input class="toggle" type="checkbox" ng-model="todo.completed" ng-
change="toggleCompleted(todo)">
<label ng-dblclick="editTodo(todo)">{{todo.title}}</label>
<button class="destroy" ng-click="removeTodo(todo)"></button>
</div>
<form ng-submit="saveEdits(todo, 'submit')">
<input class="edit" ng-trim="false" ng-model="todo.title" todo-
escape="revertEdits(todo)" ng-blur="saveEdits(todo, 'blur')" todo-focus="todo
== editedTodo">
</form>
</li>
</ul>
</section>
TODO Angluar JS
● plnkr.co 로 UI 테스트
○ Directive
■ todoEscape
■ todoFocus
http://plnkr.
co/edit/8DmBdPz90gCK3dxdyTqV?
p=preview
todoFocus.js todoEscape.js
Contact
NHNENT
협업시스템 김정기
kim.jeongki@example.com

Mais conteúdo relacionado

Mais procurados

Angular Seminar [한빛미디어 리얼타임 세미나]
Angular Seminar [한빛미디어 리얼타임 세미나]Angular Seminar [한빛미디어 리얼타임 세미나]
Angular Seminar [한빛미디어 리얼타임 세미나]Woojin Joe
 
Angular 2 rc5 조사
Angular 2 rc5 조사Angular 2 rc5 조사
Angular 2 rc5 조사Rjs Ryu
 
Front end dev 2016 & beyond
Front end dev 2016 & beyondFront end dev 2016 & beyond
Front end dev 2016 & beyondJae Sung Park
 
Angular2를 위한 타입스크립트
Angular2를 위한 타입스크립트Angular2를 위한 타입스크립트
Angular2를 위한 타입스크립트Jin wook
 
Mean 스택을 사용한 IoT 개발
Mean 스택을 사용한 IoT 개발Mean 스택을 사용한 IoT 개발
Mean 스택을 사용한 IoT 개발Jay Park
 
Angular는 사실 어렵지 않습니다.
Angular는 사실 어렵지 않습니다.Angular는 사실 어렵지 않습니다.
Angular는 사실 어렵지 않습니다.장현 한
 
혁신적인 웹컴포넌트 라이브러리 - Polymer
혁신적인 웹컴포넌트 라이브러리 - Polymer혁신적인 웹컴포넌트 라이브러리 - Polymer
혁신적인 웹컴포넌트 라이브러리 - PolymerJae Sung Park
 
[DevOn 2013] Backbone.js로 능동적 M-V 디자인 구현하기
[DevOn 2013] Backbone.js로 능동적  M-V 디자인 구현하기[DevOn 2013] Backbone.js로 능동적  M-V 디자인 구현하기
[DevOn 2013] Backbone.js로 능동적 M-V 디자인 구현하기Gyutae Jo
 
React Native를 사용한
 초간단 커뮤니티 앱 제작
React Native를 사용한
 초간단 커뮤니티 앱 제작React Native를 사용한
 초간단 커뮤니티 앱 제작
React Native를 사용한
 초간단 커뮤니티 앱 제작Taegon Kim
 
Angular2를 위한 컴포넌트 분석과 개발
Angular2를 위한 컴포넌트 분석과 개발Angular2를 위한 컴포넌트 분석과 개발
Angular2를 위한 컴포넌트 분석과 개발Jin wook
 
목적에 맞게 Angular, React, Vue
목적에 맞게 Angular, React, Vue목적에 맞게 Angular, React, Vue
목적에 맞게 Angular, React, VueGunhee Lee
 
Facebook은 React를 왜 만들었을까?
Facebook은 React를 왜 만들었을까? Facebook은 React를 왜 만들었을까?
Facebook은 React를 왜 만들었을까? Kim Hunmin
 
Polymer, lego같이 만드는 웹어플리케이션
Polymer, lego같이 만드는 웹어플리케이션Polymer, lego같이 만드는 웹어플리케이션
Polymer, lego같이 만드는 웹어플리케이션Jeado Ko
 
웹-프론트엔드 프레임워크를 고르기 위한 팁
웹-프론트엔드 프레임워크를 고르기 위한 팁웹-프론트엔드 프레임워크를 고르기 위한 팁
웹-프론트엔드 프레임워크를 고르기 위한 팁WebFrameworks
 
T12_1_김나람_웹 기술로 구축하는 모바일 애플리케이션 - React Native
T12_1_김나람_웹 기술로 구축하는 모바일 애플리케이션 - React NativeT12_1_김나람_웹 기술로 구축하는 모바일 애플리케이션 - React Native
T12_1_김나람_웹 기술로 구축하는 모바일 애플리케이션 - React Native양재동 코드랩
 
알아봅시다, Polymer: Web Components & Web Animations
알아봅시다, Polymer: Web Components & Web Animations알아봅시다, Polymer: Web Components & Web Animations
알아봅시다, Polymer: Web Components & Web AnimationsChang W. Doh
 

Mais procurados (20)

Angular Seminar [한빛미디어 리얼타임 세미나]
Angular Seminar [한빛미디어 리얼타임 세미나]Angular Seminar [한빛미디어 리얼타임 세미나]
Angular Seminar [한빛미디어 리얼타임 세미나]
 
Angular 2 rc5 조사
Angular 2 rc5 조사Angular 2 rc5 조사
Angular 2 rc5 조사
 
Front end dev 2016 & beyond
Front end dev 2016 & beyondFront end dev 2016 & beyond
Front end dev 2016 & beyond
 
Angular2를 위한 타입스크립트
Angular2를 위한 타입스크립트Angular2를 위한 타입스크립트
Angular2를 위한 타입스크립트
 
Mean 스택을 사용한 IoT 개발
Mean 스택을 사용한 IoT 개발Mean 스택을 사용한 IoT 개발
Mean 스택을 사용한 IoT 개발
 
Angular는 사실 어렵지 않습니다.
Angular는 사실 어렵지 않습니다.Angular는 사실 어렵지 않습니다.
Angular는 사실 어렵지 않습니다.
 
혁신적인 웹컴포넌트 라이브러리 - Polymer
혁신적인 웹컴포넌트 라이브러리 - Polymer혁신적인 웹컴포넌트 라이브러리 - Polymer
혁신적인 웹컴포넌트 라이브러리 - Polymer
 
Deview2013 track1 session7
Deview2013 track1 session7Deview2013 track1 session7
Deview2013 track1 session7
 
[DevOn 2013] Backbone.js로 능동적 M-V 디자인 구현하기
[DevOn 2013] Backbone.js로 능동적  M-V 디자인 구현하기[DevOn 2013] Backbone.js로 능동적  M-V 디자인 구현하기
[DevOn 2013] Backbone.js로 능동적 M-V 디자인 구현하기
 
React Native를 사용한
 초간단 커뮤니티 앱 제작
React Native를 사용한
 초간단 커뮤니티 앱 제작React Native를 사용한
 초간단 커뮤니티 앱 제작
React Native를 사용한
 초간단 커뮤니티 앱 제작
 
Angular2를 위한 컴포넌트 분석과 개발
Angular2를 위한 컴포넌트 분석과 개발Angular2를 위한 컴포넌트 분석과 개발
Angular2를 위한 컴포넌트 분석과 개발
 
목적에 맞게 Angular, React, Vue
목적에 맞게 Angular, React, Vue목적에 맞게 Angular, React, Vue
목적에 맞게 Angular, React, Vue
 
Facebook은 React를 왜 만들었을까?
Facebook은 React를 왜 만들었을까? Facebook은 React를 왜 만들었을까?
Facebook은 React를 왜 만들었을까?
 
Polymer, lego같이 만드는 웹어플리케이션
Polymer, lego같이 만드는 웹어플리케이션Polymer, lego같이 만드는 웹어플리케이션
Polymer, lego같이 만드는 웹어플리케이션
 
웹-프론트엔드 프레임워크를 고르기 위한 팁
웹-프론트엔드 프레임워크를 고르기 위한 팁웹-프론트엔드 프레임워크를 고르기 위한 팁
웹-프론트엔드 프레임워크를 고르기 위한 팁
 
T12_1_김나람_웹 기술로 구축하는 모바일 애플리케이션 - React Native
T12_1_김나람_웹 기술로 구축하는 모바일 애플리케이션 - React NativeT12_1_김나람_웹 기술로 구축하는 모바일 애플리케이션 - React Native
T12_1_김나람_웹 기술로 구축하는 모바일 애플리케이션 - React Native
 
Web_07_Rails Advanced
Web_07_Rails AdvancedWeb_07_Rails Advanced
Web_07_Rails Advanced
 
역시 Redux
역시 Redux역시 Redux
역시 Redux
 
알아봅시다, Polymer: Web Components & Web Animations
알아봅시다, Polymer: Web Components & Web Animations알아봅시다, Polymer: Web Components & Web Animations
알아봅시다, Polymer: Web Components & Web Animations
 
[Codelab 2017] ReactJS 기초
[Codelab 2017] ReactJS 기초[Codelab 2017] ReactJS 기초
[Codelab 2017] ReactJS 기초
 

Destaque

Parts of speech : PREPOSITIONS
Parts of speech : PREPOSITIONSParts of speech : PREPOSITIONS
Parts of speech : PREPOSITIONSKs Maheta
 
3. la sedia dondolante il percorso didattico nel dettaglio
3. la sedia dondolante   il percorso didattico nel dettaglio3. la sedia dondolante   il percorso didattico nel dettaglio
3. la sedia dondolante il percorso didattico nel dettagliosafetyschoolmodel
 
Health Datapalooza 2013: Hearing from the Community - Jean Nudelman
Health Datapalooza 2013: Hearing from the Community - Jean NudelmanHealth Datapalooza 2013: Hearing from the Community - Jean Nudelman
Health Datapalooza 2013: Hearing from the Community - Jean NudelmanHealth Data Consortium
 
Webinar: Customs Enforcement of Intellectual Property Rights, May 27, 2009
Webinar:  Customs Enforcement of Intellectual Property Rights, May 27, 2009Webinar:  Customs Enforcement of Intellectual Property Rights, May 27, 2009
Webinar: Customs Enforcement of Intellectual Property Rights, May 27, 2009oscargonz
 
Procrastination Multimodal Component
Procrastination Multimodal ComponentProcrastination Multimodal Component
Procrastination Multimodal ComponentWilson Bryant
 
The Responsible Developer, Java Day, Kiev 2015
The Responsible Developer, Java Day, Kiev 2015The Responsible Developer, Java Day, Kiev 2015
The Responsible Developer, Java Day, Kiev 2015TSundberg
 
3. kids at work il percorso didattico nel dettaglio
3. kids at work   il percorso didattico nel dettaglio3. kids at work   il percorso didattico nel dettaglio
3. kids at work il percorso didattico nel dettagliosafetyschoolmodel
 
Mídia Kit
Mídia KitMídia Kit
Mídia Kitmeu BiZ
 
3. guarda come dondolo il percorso didattico nel dettaglio
3. guarda come dondolo   il percorso didattico nel dettaglio3. guarda come dondolo   il percorso didattico nel dettaglio
3. guarda come dondolo il percorso didattico nel dettagliosafetyschoolmodel
 
Health Datapalooza 2013: Data Design Diabetes Demo Day Nuduro
Health Datapalooza 2013: Data Design Diabetes Demo Day NuduroHealth Datapalooza 2013: Data Design Diabetes Demo Day Nuduro
Health Datapalooza 2013: Data Design Diabetes Demo Day NuduroHealth Data Consortium
 
Question 2 A2
Question 2 A2Question 2 A2
Question 2 A2Dan Lane
 
Health Datapalooza 2013: State of the Art - Humedica
Health Datapalooza 2013: State of the Art - HumedicaHealth Datapalooza 2013: State of the Art - Humedica
Health Datapalooza 2013: State of the Art - HumedicaHealth Data Consortium
 
Cirugía refractiva: Clínica Santa Lucía.
Cirugía refractiva: Clínica Santa Lucía.Cirugía refractiva: Clínica Santa Lucía.
Cirugía refractiva: Clínica Santa Lucía.Gabriel Puente
 
Grammar Jim Italy: Teaching Tips
Grammar Jim Italy: Teaching TipsGrammar Jim Italy: Teaching Tips
Grammar Jim Italy: Teaching TipsFria-Laroverken
 
Pengenalan Sistem Scada
Pengenalan Sistem ScadaPengenalan Sistem Scada
Pengenalan Sistem ScadaDanu Atmojo
 

Destaque (20)

kornouali
kornoualikornouali
kornouali
 
Parts of speech : PREPOSITIONS
Parts of speech : PREPOSITIONSParts of speech : PREPOSITIONS
Parts of speech : PREPOSITIONS
 
3. la sedia dondolante il percorso didattico nel dettaglio
3. la sedia dondolante   il percorso didattico nel dettaglio3. la sedia dondolante   il percorso didattico nel dettaglio
3. la sedia dondolante il percorso didattico nel dettaglio
 
Health Datapalooza 2013: Hearing from the Community - Jean Nudelman
Health Datapalooza 2013: Hearing from the Community - Jean NudelmanHealth Datapalooza 2013: Hearing from the Community - Jean Nudelman
Health Datapalooza 2013: Hearing from the Community - Jean Nudelman
 
Webinar: Customs Enforcement of Intellectual Property Rights, May 27, 2009
Webinar:  Customs Enforcement of Intellectual Property Rights, May 27, 2009Webinar:  Customs Enforcement of Intellectual Property Rights, May 27, 2009
Webinar: Customs Enforcement of Intellectual Property Rights, May 27, 2009
 
Procrastination Multimodal Component
Procrastination Multimodal ComponentProcrastination Multimodal Component
Procrastination Multimodal Component
 
The Responsible Developer, Java Day, Kiev 2015
The Responsible Developer, Java Day, Kiev 2015The Responsible Developer, Java Day, Kiev 2015
The Responsible Developer, Java Day, Kiev 2015
 
TREND_street
TREND_streetTREND_street
TREND_street
 
3. kids at work il percorso didattico nel dettaglio
3. kids at work   il percorso didattico nel dettaglio3. kids at work   il percorso didattico nel dettaglio
3. kids at work il percorso didattico nel dettaglio
 
Mídia Kit
Mídia KitMídia Kit
Mídia Kit
 
Honors College Presentation
Honors College PresentationHonors College Presentation
Honors College Presentation
 
3. guarda come dondolo il percorso didattico nel dettaglio
3. guarda come dondolo   il percorso didattico nel dettaglio3. guarda come dondolo   il percorso didattico nel dettaglio
3. guarda come dondolo il percorso didattico nel dettaglio
 
Health Datapalooza 2013: Data Design Diabetes Demo Day Nuduro
Health Datapalooza 2013: Data Design Diabetes Demo Day NuduroHealth Datapalooza 2013: Data Design Diabetes Demo Day Nuduro
Health Datapalooza 2013: Data Design Diabetes Demo Day Nuduro
 
Question 2 A2
Question 2 A2Question 2 A2
Question 2 A2
 
Health Datapalooza 2013: State of the Art - Humedica
Health Datapalooza 2013: State of the Art - HumedicaHealth Datapalooza 2013: State of the Art - Humedica
Health Datapalooza 2013: State of the Art - Humedica
 
Cirugía refractiva: Clínica Santa Lucía.
Cirugía refractiva: Clínica Santa Lucía.Cirugía refractiva: Clínica Santa Lucía.
Cirugía refractiva: Clínica Santa Lucía.
 
Grammar Jim Italy: Teaching Tips
Grammar Jim Italy: Teaching TipsGrammar Jim Italy: Teaching Tips
Grammar Jim Italy: Teaching Tips
 
Pengenalan Sistem Scada
Pengenalan Sistem ScadaPengenalan Sistem Scada
Pengenalan Sistem Scada
 
ADVERBS
ADVERBSADVERBS
ADVERBS
 
Round 1 & 2
Round 1 & 2Round 1 & 2
Round 1 & 2
 

Semelhante a Angular js quick start

다시보는 Angular js
다시보는 Angular js다시보는 Angular js
다시보는 Angular jsJeado Ko
 
Webframeworks angular js 세미나
Webframeworks angular js 세미나Webframeworks angular js 세미나
Webframeworks angular js 세미나WebFrameworks
 
Deep dive into Modern frameworks - HTML5 Forum 2018
Deep dive into Modern frameworks - HTML5 Forum 2018Deep dive into Modern frameworks - HTML5 Forum 2018
Deep dive into Modern frameworks - HTML5 Forum 2018Kenneth Ceyer
 
[114]angularvs react 김훈민손찬욱
[114]angularvs react 김훈민손찬욱[114]angularvs react 김훈민손찬욱
[114]angularvs react 김훈민손찬욱NAVER D2
 
[XECon+PHPFest 2014] jQuery 개발자에서 AngularJS 개발자 되기
[XECon+PHPFest 2014] jQuery 개발자에서 AngularJS 개발자 되기[XECon+PHPFest 2014] jQuery 개발자에서 AngularJS 개발자 되기
[XECon+PHPFest 2014] jQuery 개발자에서 AngularJS 개발자 되기Jeado Ko
 
Jenkins를 활용한 javascript 개발
Jenkins를 활용한 javascript 개발Jenkins를 활용한 javascript 개발
Jenkins를 활용한 javascript 개발지수 윤
 
Data-binding AngularJS
Data-binding AngularJSData-binding AngularJS
Data-binding AngularJSEunYoung Kim
 
Cappuccino fundamental
Cappuccino fundamentalCappuccino fundamental
Cappuccino fundamentalJeongHun Byeon
 
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기현철 조
 
Nodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjsNodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjs기동 이
 
Android Native Module 안정적으로 개발하기
Android Native Module 안정적으로 개발하기Android Native Module 안정적으로 개발하기
Android Native Module 안정적으로 개발하기hanbeom Park
 
Planning poker with jetpack
Planning poker with jetpackPlanning poker with jetpack
Planning poker with jetpackSooHwan Ok
 
자바 웹 개발 시작하기 (9주차 : 프로젝트 구현 – 추가적인 뷰)
자바 웹 개발 시작하기 (9주차 : 프로젝트 구현 – 추가적인 뷰)자바 웹 개발 시작하기 (9주차 : 프로젝트 구현 – 추가적인 뷰)
자바 웹 개발 시작하기 (9주차 : 프로젝트 구현 – 추가적인 뷰)DK Lee
 
막하는 스터디 네 번째 만남 AngularJs (20151108)
막하는 스터디 네 번째 만남 AngularJs (20151108)막하는 스터디 네 번째 만남 AngularJs (20151108)
막하는 스터디 네 번째 만남 AngularJs (20151108)연웅 조
 
Meteor React Tutorial 따라하기
Meteor React Tutorial 따라하기Meteor React Tutorial 따라하기
Meteor React Tutorial 따라하기Jiam Seo
 
Django를 Django답게, Django로 뉴스 사이트 만들기
Django를 Django답게, Django로 뉴스 사이트 만들기Django를 Django답게, Django로 뉴스 사이트 만들기
Django를 Django답게, Django로 뉴스 사이트 만들기Kyoung Up Jung
 
Dreamweaver CS5.5 를 이용한 jQueryMobile 개발
Dreamweaver CS5.5 를 이용한 jQueryMobile 개발Dreamweaver CS5.5 를 이용한 jQueryMobile 개발
Dreamweaver CS5.5 를 이용한 jQueryMobile 개발JongKwang Kim
 

Semelhante a Angular js quick start (20)

다시보는 Angular js
다시보는 Angular js다시보는 Angular js
다시보는 Angular js
 
Webframeworks angular js 세미나
Webframeworks angular js 세미나Webframeworks angular js 세미나
Webframeworks angular js 세미나
 
Deep dive into Modern frameworks - HTML5 Forum 2018
Deep dive into Modern frameworks - HTML5 Forum 2018Deep dive into Modern frameworks - HTML5 Forum 2018
Deep dive into Modern frameworks - HTML5 Forum 2018
 
[114]angularvs react 김훈민손찬욱
[114]angularvs react 김훈민손찬욱[114]angularvs react 김훈민손찬욱
[114]angularvs react 김훈민손찬욱
 
[XECon+PHPFest 2014] jQuery 개발자에서 AngularJS 개발자 되기
[XECon+PHPFest 2014] jQuery 개발자에서 AngularJS 개발자 되기[XECon+PHPFest 2014] jQuery 개발자에서 AngularJS 개발자 되기
[XECon+PHPFest 2014] jQuery 개발자에서 AngularJS 개발자 되기
 
Jenkins를 활용한 javascript 개발
Jenkins를 활용한 javascript 개발Jenkins를 활용한 javascript 개발
Jenkins를 활용한 javascript 개발
 
Data-binding AngularJS
Data-binding AngularJSData-binding AngularJS
Data-binding AngularJS
 
Cappuccino fundamental
Cappuccino fundamentalCappuccino fundamental
Cappuccino fundamental
 
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
 
Nodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjsNodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjs
 
Android Native Module 안정적으로 개발하기
Android Native Module 안정적으로 개발하기Android Native Module 안정적으로 개발하기
Android Native Module 안정적으로 개발하기
 
Jqm+appspresso
Jqm+appspressoJqm+appspresso
Jqm+appspresso
 
Planning poker with jetpack
Planning poker with jetpackPlanning poker with jetpack
Planning poker with jetpack
 
MVP 패턴 소개
MVP 패턴 소개MVP 패턴 소개
MVP 패턴 소개
 
자바 웹 개발 시작하기 (9주차 : 프로젝트 구현 – 추가적인 뷰)
자바 웹 개발 시작하기 (9주차 : 프로젝트 구현 – 추가적인 뷰)자바 웹 개발 시작하기 (9주차 : 프로젝트 구현 – 추가적인 뷰)
자바 웹 개발 시작하기 (9주차 : 프로젝트 구현 – 추가적인 뷰)
 
막하는 스터디 네 번째 만남 AngularJs (20151108)
막하는 스터디 네 번째 만남 AngularJs (20151108)막하는 스터디 네 번째 만남 AngularJs (20151108)
막하는 스터디 네 번째 만남 AngularJs (20151108)
 
Meteor React Tutorial 따라하기
Meteor React Tutorial 따라하기Meteor React Tutorial 따라하기
Meteor React Tutorial 따라하기
 
Django를 Django답게, Django로 뉴스 사이트 만들기
Django를 Django답게, Django로 뉴스 사이트 만들기Django를 Django답게, Django로 뉴스 사이트 만들기
Django를 Django답게, Django로 뉴스 사이트 만들기
 
Dreamweaver CS5.5 를 이용한 jQueryMobile 개발
Dreamweaver CS5.5 를 이용한 jQueryMobile 개발Dreamweaver CS5.5 를 이용한 jQueryMobile 개발
Dreamweaver CS5.5 를 이용한 jQueryMobile 개발
 
Hacosa jquery 1th
Hacosa jquery 1thHacosa jquery 1th
Hacosa jquery 1th
 

Angular js quick start

  • 2. 개요 목표 ● AngularJS의 기본 개념을 익힌다. ● TodoApp 코드 분석을 통해 동작원리 및 실습 과정을 소개한다.
  • 3. 개요 대상 ● jQuery의 기본 사용법을 아시는 분 ● AngularJS를 들어 봤거나 기본 기능만 테스트 해보신 분 ● 실무에 적용해보고 싶으신 분
  • 5. Angluar JS를 선택하는 이유 ● 자바스크립트 코드량 감소 ● 단순 자바스크립트 객체 데이터 모델을 이용한 view model 양방향 바인딩 ● 재사용할 수 있는 UI 컴포넌트 개발 및 다양한 오픈소스 활용
  • 6. Angluar JS를 선택하는 이유 ● DI를 이용한 모듈 분리와 테스트의 용이성 ● HTML&CSS 마크업과 JS 개발의 분리 ● 세계적으로 가장 많이 사용하는 프레임워크
  • 7. Angluar JS의 특징 ● MVW 개발방식 ● 양방향 데이터 바인딩 ● 지시자를 이용한 컴포넌트화
  • 8. Angluar JS의 특징 ● AngularJS 템플릿 ● 의존성 주입 ● 테스트 프레임워크
  • 9. Angluar JS의 특징 ● SPA를 위한 라우터 ● $q, $timeout 서비스를 이용한 비동기 프로그래밍 지원
  • 11. Angluar JS의 특징 ● MVW 개발방식 ○ Model View Whatever
  • 12. Angluar JS의 특징 ● MVW 개발방식 ○ 구성요소
  • 13. Angluar JS의 특징 ● MVW 개발방식 ○ 구성요소 흐름도
  • 14. Angluar JS의 특징 ● 양방향 데이터 바인딩 http://todomvc.com/examples/angularjs/#/
  • 15. Angluar JS의 특징 ● 양방향 데이터 바인딩 angular.module('todomvc') .controller('TodoCtrl', function TodoCtrl($scope, $routeParams, $filter, store) { $scope.todos = store.todos; $scope.newTodo = ''; $scope.editedTodo = null; … $scope.addTodo = function () { … }; $scope.editTodo = function (todo) { … }; $scope.saveEdits = function (todo, event) { … }; $scope.revertEdits = function (todo) { … }; $scope.removeTodo = function (todo) { … }; $scope.saveTodo = function (todo) { … }; ... });
  • 16. Angluar JS의 특징 ● 양방향 데이터 바인딩 <section id="main" ng-show="todos.length" ng-cloak> <input id="toggle-all" type="checkbox" ng-model="allChecked" ng-click="markAll (allChecked)"> <label for="toggle-all">Mark all as complete</label> <ul id="todo-list"> <li ng-repeat="todo in todos | filter:statusFilter track by $index"> <div class="view"> <input class="toggle" type="checkbox" ng-model="todo.completed" ng- change="toggleCompleted(todo)"> <label ng-dblclick="editTodo(todo)">{{todo.title}}</label> <button class="destroy" ng-click="removeTodo(todo)"></button> </div> <form ng-submit="saveEdits(todo, 'submit')"> <input class="edit" ng-trim="false" ng-model="todo.title" todo-escape=" revertEdits(todo)" ng-blur="saveEdits(todo, 'blur')" todo-focus="todo == editedTodo"> </form> </li> </ul> </section>
  • 17. Angluar JS의 특징 ● 양방향 데이터 바인딩
  • 18. Angluar JS의 특징 ● 의존성 주입
  • 19. Angluar JS의 특징 ● 의존성 주입 ○ 모듈 의존성 angular.module('todomvc', [ ‘ngCookies’, ‘ngRoute’, ‘ui.sortable’ ]) .config(function($routeProvider){ … });
  • 20. Angluar JS의 특징 ● 의존성 주입 angular.module('todomvc') .controller('TodoCtrl', function TodoCtrl($scope, $routeParams, filter, store) { $scope.todos = store.todos; $scope.newTodo = ''; $scope.editedTodo = null; … $scope.addTodo = function () { … }; $scope.editTodo = function (todo) { … }; $scope.saveEdits = function (todo, event) { … }; $scope.revertEdits = function (todo) { … }; $scope.removeTodo = function (todo) { … }; $scope.saveTodo = function (todo) { … }; ... });
  • 21. Angluar JS의 특징 ● AngularJS 템플릿
  • 22. Angluar JS의 특징 ● 지시자 (Directive) ○ 재활용가능한 웹 컴포넌트
  • 23. Angluar JS의 특징 ● 지시자 (Directive)
  • 24. Angluar JS의 특징 ● 지시자 (Directive) ○ 코드로 표현하자면 … var html = ‘<div ng-bind=”express”></div>”; //1단계 ) HTML을 DOM으로 변환 var template = angular.element(html); //2단계) 템플릿 컴파일 하기 var linkFn = $compile(template); //3단계) 컴파일된 템플릿과 스코프 객체를 연결 var element = linkFn(scope); //4단계) 부모 DOMㅇP CNRK parent.appendChild(element);
  • 25. Angluar JS의 특징 ● 테스트 프레임워크
  • 26. Angluar JS의 특징 ● 테스트 프레임워크 ○ BDD ■ describe ● it (function () { 'use strict'; describe('Todo Controller', function () { var ctrl, scope, store; // Load the module containing the app, only 'ng' is loaded by default. beforeEach(module('todomvc')); beforeEach(inject(function ($controller, $rootScope, localStorage) { scope = $rootScope.$new(); ... ctrl = $controller('TodoCtrl', { $scope: scope, store: store }); })); it('should have all Todos completed', function () { scope.$digest(); expect(scope.allChecked).toBeTruthy(); }); }());
  • 28. TODO Angluar JS ● 참고 예제 http://todomvc.com/examples/angularjs/#/ https://github.com/tastejs/todomvc/tree/gh- pages/examples/angularjs
  • 29. TODO Angluar JS ● 기능 분석 * 할일 등록 * INPUT 입력 후 목록 하단에표시 * TODO + DONE 수정 * 항목 더블 클릭 시 수정 모드 * 할일 목록 * 기본 * All - (TODO + DONE) * Active - TODO(해야할일만) * Completed - DONE(완료된일만) * 상태 변경 * 선택 업무 상태 변경 (TODO <-> DONE) * 전체 업무 상태 변경 (TODO <-> DONE) * 완료 업무 삭제 * 항목 DONE 업무 삭제 [X버튼] * 항목 DONE 업무 삭제 [Clear Completed] * 전체 DONE 업무 삭제 * 상태 표시 * TODO 개수 * 필터 버튼 표시 [All, Active, Completed] * Clear Completed http://todomvc.com/examples/angularjs/#/ https://github.com/tastejs/todomvc/tree/gh- pages/examples/angularjs
  • 30. TODO Angluar JS ● 기능 분석 ○ 파일 구조 * index.html * HTML 페이지구성 및 angular template 정의 * app.js * angular bootstrap 및 라우팅정의 * todoCtrl.js * 기능별외부 scope function 정의 * todoStorage.js * todo list 및 item 읽기/저장/수정/삭제 기능 정의 서비스 * todoEscape.js * keyevent escape 처리 directive * todoFocus.js * 해당영역input focus 처리 directivehttp://plnkr. co/edit/8DmBdPz90gCK3dxdyTqV? p=preview
  • 31. TODO Angluar JS ● plnkr.co 로 UI 테스트 ○ angular template 전체 http://plnkr. co/edit/8DmBdPz90gCK3dxdyTqV? p=preview
  • 32. TODO Angluar JS ● plnkr.co 로 UI 테스트 ○ bootstrap ■ domready event 시 ng-app이 지정된 element를 대상으 로 angular 초기화 실행 ■ 모듈 정의 http://plnkr. co/edit/8DmBdPz90gCK3dxdyTqV? p=preview URL Path가 ‘/’ or /#/active or /#/completed 일때 TodoCtrl과 todomvc-index.html 적용 -> URL Base SPA 기본 작동 app.js index.html 모듈 정 의
  • 33. TODO Angluar JS ● plnkr.co 로 UI 테스트 ○ Service ■ todoStorage ● todo list ● todo item 읽기/저장/ 수정/삭제 http://plnkr. co/edit/8DmBdPz90gCK3dxdyTqV? p=preview todoCtrl.jstodoStorage.js 모듈 사 용
  • 34. TODO Angluar JS ● plnkr.co 로 UI 테스트 ○ Service ■ todoStorage ● todo list ● todo item 읽기/저장/ 수정/삭제 http://plnkr. co/edit/8DmBdPz90gCK3dxdyTqV? p=preview todoCtrl.jstodoStorage.js 모듈 사 용 모듈 주 입 모듈 주 입
  • 35. TODO Angluar JS ● plnkr.co 로 UI 테스트 ○ Angular Directive ■ ng-${DIRECITVENAME} ■ ng-repeat, ng-if, ng-show ■ ng-change, ng-click ... http://plnkr. co/edit/8DmBdPz90gCK3dxdyTqV? p=preview <section id="main" ng-show="todos.length" ng-cloak> <input id="toggle-all" type="checkbox" ng-model="allChecked" ng-click="markAll (allChecked)"> <label for="toggle-all">Mark all as complete</label> <ul id="todo-list"> <li ng-repeat="todo in todos | filter:statusFilter track by $index"> <div class="view"> <input class="toggle" type="checkbox" ng-model="todo.completed" ng- change="toggleCompleted(todo)"> <label ng-dblclick="editTodo(todo)">{{todo.title}}</label> <button class="destroy" ng-click="removeTodo(todo)"></button> </div> <form ng-submit="saveEdits(todo, 'submit')"> <input class="edit" ng-trim="false" ng-model="todo.title" todo- escape="revertEdits(todo)" ng-blur="saveEdits(todo, 'blur')" todo-focus="todo == editedTodo"> </form> </li> </ul> </section>
  • 36. TODO Angluar JS ● plnkr.co 로 UI 테스트 ○ Directive ■ todoEscape ■ todoFocus http://plnkr. co/edit/8DmBdPz90gCK3dxdyTqV? p=preview todoFocus.js todoEscape.js