angular js

20
WHAT IS IT, HOW DO I USE IT AND WHY

Upload: e2-partners

Post on 10-May-2015

352 views

Category:

Software


0 download

DESCRIPTION

Intro session of AngularJS by Thomas Vriens at the E2 offices.

TRANSCRIPT

Page 1: Angular js

WHAT IS IT, HOW DO I USE IT AND WHY

Page 2: Angular js

Agenda• What is Angular (15 min)

• Why Angular (15 min)• What makes it different from other JavaScript frameworks

• Angular vs ASP.NET MVC

• How do I use it (45 min)• Controllers

• Scopes

• Providers

• Directives

• Questions

Page 3: Angular js

What is Angular

Page 4: Angular js

What is Angular – Part 1• Initial release 2009

• Open-source

• SPA framework

• Model-View-Whatever

• Declarative programming

• Developed and maintained by Google

Page 5: Angular js

What is Angular – Part 2• Modular, Extensible• angular.js

• angular-animate.js, angular-route.js, angular-touch.js, …

• Testable

• Browser Compatibility• Current version (1.2.x) requires pollyfills for IE 7 and bellow

• Version 1.3 will drop IE 8 and bellow

• Active community• Documentation

• Tutorials

• Third-party directives

Page 6: Angular js

Why Angular

Page 7: Angular js
Page 8: Angular js

• Initial release 2010

• Dependencies:• Underscore.js

• Backbone.Router

• Backbone.View

• jQuery and json2.js for backwards compatibility

• Many modules available

Page 9: Angular js

• Initial release 2011

• Dependencies:• jQuery

• Handlebars.js

• Pure MVC

Page 10: Angular js

• Dependencies:• jQuery

• Knockout

• Require.js

• Lead developer and architect Rob Eisenberg working on AngularJS V2

• MVVM

Page 11: Angular js

AngularJS & MVC• Do I need to choose?

• MVC & jQuery

• Type safety

• Routing

• Typescript

Page 12: Angular js

How do I use it• Controllers

• How to deal with scopes

• Providers• Service

• Factory

• Provider

• Directives

Page 13: Angular js

ControllersDEMO!!!

Page 14: Angular js

Scopes• ngRepeat and scopes

• Always have a dot in your expression

• JavaScript Prototypical Inheritance

• Functions/objects are safe, parameters are not

• $parent

Page 15: Angular js

Providers• Service

• Factory

• Provider

Page 16: Angular js

Providers - Servicevar myApp = angular.module('myApp', []);

myApp.service('helloWorldFromService', function () {this.sayHello = function () {

return "Hello, World!";};

});

Page 17: Angular js

Providers - Factoryvar myApp = angular.module('myApp', []);

myApp.factory('helloWorldFromFactory', function() {return {

sayHello: function() {return "Hello, World!";

}};

});

Page 18: Angular js

Providers - Providervar myApp = angular.module('myApp', []);

myApp.provider('helloWorld', function() {this.name = 'Default';this.$get = function() {

var name = this.name;return {

sayHello: function() {return "Hello, " + name + "!";

}}

};this.setName = function (name) {

this.name = name;};

});

// Configure a provider myApp.config(function (helloWorldProvider) {

helloWorldProvider.setName('World');});

Page 19: Angular js

Directives• AngularJS HTML compiler ($compile)

• Directive names, ngModel or is it ng-model?

• HTML validators

• Usage• Tag

• Attribute

• Comment

• Class

• Template options

Page 20: Angular js

Questions?