Charla dada dentro de la Semana del Impulso TIC
DevFest Asturias, GDG Asturias
Avilés, Centro Niemeyer, 3 de noviembre de 2016
https://goo.gl/Udysyl
Angular 1 estaba muerto, en el verano de 2015 nadie quería programar. Sobre todo porque iba a salir Angular 2.
¿Qué hizo que esto cambiase? La salida de Angular 1.5 y la nueva arquitectura de componentes hizo que volviese a la vida y que el cambio a Angular 2 fuera mucho más simple.
How AI, OpenAI, and ChatGPT impact business and software.
El viaje de Angular1 a Angular2
1. El viaje de Angular1 a Angular2
Antonio de la Torre
#DevFestAsturias 03/11/2016
@adelatorrefoss
2. Angular
“AngularJS is a structural
framework for dynamic web apps.
It lets you use HTML as your
template language and lets you
extend HTML's syntax to express
your application's components
clearly and succinctly. Angular's
data binding and dependency
injection eliminate much of the code
you would otherwise have to write.
Angular teaches the browser new
syntax through a construct we call
directives.“
https://docs.angularjs.org/guide/introduction
13. from
angular.module('directives')
.directive('pony', function(){
return {
scope: {
name: '='
},
controllerAs: 'vm',
controller: function($scope){
var vm = this;
vm.name = $scope.name;
// we have to add a watcher on $scope.name to make this work
$scope.$watch('name', function(newName){
vm.name = newName;
});
},
template: '<p>{{vm.name}}</p>'
}
});
22. Three Principles of Redux
Single source of truth
The state of your whole application is stored in an object tree within a single store.
State is read-only
The only way to change the state is to emit an action, an object describing what
happened.
Changes are made with pure functions
To specify how the state tree is transformed by actions, you write pure reducers.http://redux.js.org/docs/introduction/ThreePrinciples.html
26. “The Javascript pendulum has swung from
restrictive, monolithic frameworks to
modular, boilerplate-hindered libraries.”
EricClemmons
https://medium.com/@ericclemmons/javascript-fatigue-48d4011b6fc4#.nzcp66xkh
28. Don’t try to know everything – it’s impossible in
modern web development.
I find it important to remain human. Don’t overdo
discipline, don’t become a life improvement
machine. Periods of boredom and doing nothing are
important for recuperating and inspiration.
AxelRauschmayer
http://www.2ality.com/2016/02/js-fatigue-fatigue.html
30. Guías de estilo de
John Papa y Todd Motto
para Angular 1.4 mejoró la situación
https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md
https://github.com/toddmotto/angular-styleguide
37. La arquitectura de componentes
● Solo controlan su propia vista y datos
● Tienen una API bien definida
● Una aplicación es un árbol de componentes
● Eliminó la magia negra de las directivas
● No hace falta conocer el ciclo de compilación a fondo
● No es necesario acceder al $scope
39. Migrating from 1.4 to 1.5
https://docs.angularjs.org/guide/migration
Angular 1.5 takes a big step towards preparing developers for a smoother transition to
Angular 2 in the future. Architecting your applications using components, multi-slot
transclusion, one-way bindings in isolate scopes, using lifecycle hooks in directive
controllers and relying on native ES6 features (such as classes and arrow functions) are
now all possible with Angular 1.5.
41. Guía de estilo Angular 1.5 de Todd Motto
Scope
- Stateful components
- Stateless components
Directives
- Directives should be used solely for decorating the DOM.
Eventos
- Comunicación con el padre por eventos. $event
42. Pasar datos de componentes hacia arriba:
About events
https://toddmotto.com/angular-1-5-lifecycle-hooks
Okay, bear with me, we’re in the final phase. This is where things get… interesting.
Instead of just passig back this.user into the function, we’re going to fake an $event
Object, which complies with how Angular 2 does this (using EventEmitter), and also
provides global consistency between your templates to fetch data back through the
43.
44. El lío del router
● ngRoute para v1.4
● ngComponentRouter para v1.5
● RouterModule para v2
● ui-router (estándar de facto en todas)
46. Ventajas
● Componentes
● Independiente de la plataforma
● Web workers
● Server side rendering
● Typescript
● Rx
http://slides.com/gruizdevilla/angular-2-workshop#/
https://www.youtube.com/watch?v=7vSPfmHWIjA
49. Ventajas
● ES6 (Módulos y clases)
● No ng-class, no ng-click, all are DOM native
attributes.
An Angular 2 Force Awakens - John Papa
Ng Conf 2016 4 May
55. Angular 2 Style Guide by John Papa
The Angular 2 Style Guide
https://github.com/johnpapa/angular-styleguide/blob/master/a2/README.md
“The Angular 2 Style Guide has been moved
to the Official Angular 2 docs.”
56. Angular 2 migration guide by Todd Motto
“Convert your Angular 1 knowledge into Angular 2.
Select a topic and start learning!”
http://ngmigrate.telerik.com/