Webbramverk, 1DV450
Linnéuniversitetet, vt 2016



Klientramverk

AngularJS

Nya krav på klientapplikationer - SPA

Mer logik på klienten, BaaS


Baas

JavaScript frameworks

http://github.com/showcases/front-end-javascript-frameworks

Gemensamma delar

"Full-stack" klientramverk

AngularJS

Min erfarenhet av javascriptramverk Varför valde jag angular?

Min erfarenhet av javascriptramverk Varför valde jag angular?

AngularJS

Vem, vad, community, utveckling

Filosofi och designmål

MVC / MVVM / MVW

Foto cc by: http://www.flickr.com/photos/nyuhuhuu/

Having said, I'd rather see developers build kick-ass apps that are well-designed and follow separation of concerns, than see them waste time arguing about MV* nonsense. And for this reason, I hereby declare AngularJS to be MVW framework - Model-View-Whatever. Where Whatever stands for "whatever works for you" - Igor Minar 19 juli 2012

Foto cc by: http://www.flickr.com/photos/83633410@N07/

Utvecklingsmiljö

Att tänka på

Hello John!

Visa hello world Prata om directives Bygg vidare med lista på lag

$scope (angularjs 1.5 and before)

Alternativ syntax

Visa hello world Prata om directives Bygg vidare med lista på lag

Moduler och Dependency injection

!-- MVC architecture example-->

Exempel - Modules

Exempel med egen controller-fil

Egna moduler

Registreras i applikationen via "recept" som bygger upp objekten och gör dessa tillgängliga för DI. http://stackoverflow.com/questions/15666048/angularjs-service-vs-provider-vs-factory

Foto cc by: http://www.flickr.com/photos/seattlemunicipalarchives/

!-- MVC architecture example-->

Exempel - Adding service

Visa ett exempel med controllers i olika filer

Routing

Partial views

Exempel routing och views

Applikationsstruktur

app/
----- controllers/
---------- mainController.js
---------- otherController.js
----- directives/
---------- mainDirective.js
---------- otherDirective.js
----- services/
---------- userService.js
---------- itemService.js
----- js/
---------- bootstrap.js
---------- jquery.js
----- app.js
views/
----- mainView.html
----- otherView.html
index.html

What if > 10 controllers?

app/
----- shared/   // acts as reusable components or partials of our site
---------- sidebar/
--------------- sidebarDirective.js
--------------- sidebarView.html
----- components/   // each component is treated as a mini Angular app
---------- home/
--------------- homeController.js
--------------- homeService.js
--------------- homeView.html
---------- blog/
--------------- blogController.js
--------------- blogService.js
--------------- blogView.html
----- app.module.js
----- app.routes.js
assets/
----- img/      // Images and icons for your app
----- css/      // All styles and style related files (SCSS or LESS files)
----- js/       // JavaScript files written for your app that are not for angular
----- libs/     // Third-party libraries such as jQuery, Moment, Underscore, etc.
index.html

Nästa gång