angularjs gÇô tutorial day #1

18
AngularJS – Tutorial Day #1 By George

Upload: georgesoosai

Post on 25-Jan-2016

220 views

Category:

Documents


0 download

DESCRIPTION

tr

TRANSCRIPT

Page 1: AngularJS GÇô Tutorial Day #1

AngularJS – Tutorial Day #1

By

George

Page 2: AngularJS GÇô Tutorial Day #1

Agenda

AngularJS Introduction

Model-View-Controller (MVC pattern)

Single Page Application(SPA)

First Program

Application Execution

Data Binding

Assignments

Page 3: AngularJS GÇô Tutorial Day #1

AngularJS Introduction

What ? AngularJS is a JavaScript MVC(Model-View-Controller) structured framework

for dynamic web applications

It is the client-sided, so all these things are happening in browsers

Helps to running single-page applications

Goal is to make browser-based applications with model–view–controller (MVC) capability

Helps to make both development and testing easier.

AngularJS is developed by Googler and supported by Googler

Page 4: AngularJS GÇô Tutorial Day #1

AngularJS Introduction Why ?

many other front-end frameworks available in the web world like Backbone, Knockout

, Ember, Spline -- They all have many pros & Cons

With AngularJS:

Write lesser code

Reuse components

Two-way-data-binding

Dependency Injection

Form Validation

Helps end-to-end Testing

Page 5: AngularJS GÇô Tutorial Day #1

Model-View-Controller Architecture

Page 6: AngularJS GÇô Tutorial Day #1

MVC Event Work flow

Page 7: AngularJS GÇô Tutorial Day #1

Single Page Application

Page 8: AngularJS GÇô Tutorial Day #1

Single Page Application

Page 9: AngularJS GÇô Tutorial Day #1

First Program - AngularJS

First Step : HTML Page Second Step: include the AngularJS JavaScript file 

Page 10: AngularJS GÇô Tutorial Day #1

First Program - AngularJS

Third : - ng-app attribute to the root HTML element

Fourth: - A view is a section of HTML

Page 11: AngularJS GÇô Tutorial Day #1

First Program - AngularJS

Fifth: need a controller function

The angular object is a global object created by the AngularJS JavaScript which is included at the beginning of the page.

The controller() function call is what registers the controller function itself.

Page 12: AngularJS GÇô Tutorial Day #1

Application Execution First:

The HTML document is loaded into the browser, and evaluated by the browser.

AngularJS JavaScript file is getting loaded

angular global object is created

JavaScript which registers controller functions is executed

Second:

AngularJS scans through the HTML to look for AngularJS apps and views4

When AngularJS finds a view it connects that view to the corresponding controller

function.

Page 13: AngularJS GÇô Tutorial Day #1

Application Execution Third:

AngularJS executes the controller functions and update (render) the views with data

from the model populated by the controller. The page is now ready.

Fourth:

AngularJS listens for browser events (e.g. input fields being changed, buttons clicked,

the mouse moved etc.)

If any of these browser events require a view to change, AngularJS will update the

view correspondingly.

If the event requires that the corresponding controller function is called, AngularJS will

do that too.

Page 14: AngularJS GÇô Tutorial Day #1

Any Question So far ?

Page 15: AngularJS GÇô Tutorial Day #1

Two-Way-Data-Binding

Two way data binding in AngularJS handles the model view synchronization

Page 16: AngularJS GÇô Tutorial Day #1

Move On To Examples

Page 17: AngularJS GÇô Tutorial Day #1

Assignments Create a “Hello World” program using

AngulrJS – Make use of “angularJS” library and “ng-app” directive – Also, create a simple controller – use that controller to hold the model scope – And, bind that model scope into the views

Page 18: AngularJS GÇô Tutorial Day #1

Questions ?