angularjs - the folly of choice

51

Upload: oleg-podsechin

Post on 15-May-2015

1.557 views

Category:

Technology


1 download

DESCRIPTION

An intro to AngularJS and some experiences of using it to build https://starthq.com

TRANSCRIPT

Page 1: AngularJS - the folly of choice
Page 2: AngularJS - the folly of choice

communityjs.org

Page 3: AngularJS - the folly of choice

StartHQ

Page 4: AngularJS - the folly of choice

Toolkits vs. Frameworks

Page 5: AngularJS - the folly of choice
Page 6: AngularJS - the folly of choice
Page 7: AngularJS - the folly of choice

Toolkits vs. Frameworks

● Toolkit: collection of libraries

some assembly required

● Libraries should “do one thing and do it well”

● Inversion of control

You call a library, but a framework calls you

Page 8: AngularJS - the folly of choice

A Bit of History

Page 9: AngularJS - the folly of choice
Page 10: AngularJS - the folly of choice
Page 11: AngularJS - the folly of choice
Page 12: AngularJS - the folly of choice

AngularJS

Page 13: AngularJS - the folly of choice
Page 14: AngularJS - the folly of choice

AngularJS

● What HTML would have been, had it been designed for building web apps

● 80% of code deals with manipulating the DOM

AngularJS makes this go away

● Definitely a standalone framework

modules, templating, dependency injection, events, services, promises, testing, directives, http, interceptors, history

Page 15: AngularJS - the folly of choice

Key Features

Page 16: AngularJS - the folly of choice
Page 17: AngularJS - the folly of choice

Key Features

● Declarative – not imperative

Two way data binding

● Doesn't abstract away the DOM

Augments it with directives

● More than one way to do the same thing

Page 18: AngularJS - the folly of choice

Scopes

Page 19: AngularJS - the folly of choice
Page 20: AngularJS - the folly of choice

Scopes

• creating a scope & controller$rootScope

• prototypal inheritance

• scope attributes & methods

• importance of the dot

Page 21: AngularJS - the folly of choice

Templates

Page 22: AngularJS - the folly of choice
Page 23: AngularJS - the folly of choice

Templates

• Interpolationng-directive alternative

• ng-show, ng-hideng-cloak

• ng-repeat<li ng-repeat=”item in items”>{{item.name}}</li>

• logic can be templates

Page 24: AngularJS - the folly of choice

Modules

Page 25: AngularJS - the folly of choice
Page 26: AngularJS - the folly of choice

Modules

var app = angular.module('app', [/* deps */]) .config([..., function() {}]) .run([..., function() {}]);

• convenience methodscontroller, directive, filter, value, factory, provider

ngmodules.org

Page 27: AngularJS - the folly of choice

Dependency Injection

Page 28: AngularJS - the folly of choice
Page 29: AngularJS - the folly of choice

Dependency Injection

• inversion of control, removal of global state– Important for testing

• function TodoCtrl($scope) {}

• app.controller('TodoCtrl', ['$scope', function() {}]);

Page 30: AngularJS - the folly of choice

Views

Page 31: AngularJS - the folly of choice
Page 32: AngularJS - the folly of choice

Views

• ng-view

• ng-include src="'/navbar.html'"

Page 33: AngularJS - the folly of choice

Routing

Page 34: AngularJS - the folly of choice
Page 35: AngularJS - the folly of choice

Routing

$locationProvider.html5Mode(true);$routeProvider.when('/config', { templateUrl:'/views/config.html', controller:'Config'});

$routeProvider.otherwise({ redirectTo:'/' });

Page 36: AngularJS - the folly of choice

Directives

Page 37: AngularJS - the folly of choice
Page 38: AngularJS - the folly of choice

Directives

app.directive('ngLoad', function() { return function($scope, element) { });

• wrapping jQuery plugins$scope.watch, $scope.apply

• web components

Page 39: AngularJS - the folly of choice

Other Tools

Page 40: AngularJS - the folly of choice
Page 41: AngularJS - the folly of choice

Other Tools

• Services$http, $location

• Events

• Filters

• Promises

$q

Page 42: AngularJS - the folly of choice

Testing

Page 43: AngularJS - the folly of choice
Page 44: AngularJS - the folly of choice

Testing

• Unit tests

• End to end tests

• angular-seed project

• Karma test runner

Page 45: AngularJS - the folly of choice

Study Material

Page 46: AngularJS - the folly of choice
Page 47: AngularJS - the folly of choice

Study Material

docs.angular.org/tutorial

www.egghead.io

www.youtube.com/user/angularjs

github.com/olegp/nexus

Page 48: AngularJS - the folly of choice
Page 49: AngularJS - the folly of choice

Conclusion

Page 50: AngularJS - the folly of choice
Page 51: AngularJS - the folly of choice

Thank you!

@olegpodsechin

github.com/olegp

starthq.com