pdonorio / restangulask

FRONTEND(Flask and Angular interface) + BACKEND(Flask Rest API)
MIT License
3 stars 2 forks source link

Migration to angularjs 2? #24

Open pdonorio opened 8 years ago

pdonorio commented 8 years ago

A good starting point could be angular-cli:

https://scotch.io/tutorials/use-the-angular-cli-for-faster-angular-2-projects

pdonorio commented 8 years ago

Also moving towards ES6 this is a package manager that is really shining:

https://github.com/rollup/rollup

mdantonio commented 8 years ago

python-like imports... interesting

pdonorio commented 8 years ago

Just to add comparison to the discussion: http://aurelia.io/docs.html#/aurelia/framework/latest/doc/article/getting-started

pdonorio commented 8 years ago

Another important concept is that Angularjs 1.5 has added few things which lie in the middle of angular 1 and 2. For example see how components (ex directives) works now:

https://toddmotto.com/angular-1-5-lifecycle-hooks

pdonorio commented 8 years ago

Also, to get up to speed with 1.5, from https://toddmotto.com/rewriting-angular-styleguide-angular-2:

These still exist in Angular 1.x, however I feel they should be treated as deprecated and advise against them.

Two-way databinding through { foo: '=' } syntax
controllerAs syntax
$scope in controllers
$scope.$watch, seriously, you don’t need it (link function is ok for watching attributes/plugin properties etc)
The event system (in the application layer, for routing statechange events for authorisation are still a good use case)
These properties on Directives:
scope
bindToController
controller
controllerAs
require
template
templateUrl
transclude
Why? Use .component() because that’s the correct tool now
The .factory() method
Use an ES2015 Class for a Service, like in Angular 2
The .controller() method
Use controller: fn on components only
Using template: '<my-component>' with ui-router
Favour component: 'myComponent' and route to components
Some form of router.js file
We now have “routed components” with individual routing definitions
pdonorio commented 8 years ago

A free angularjs 2 video course is here: http://courses.angularclass.com/courses/angular-2-fundamentals

It requires registration.

pdonorio commented 8 years ago

Slides to make up to the new system: http://slides.com/austinmcdaniel/angular-2/#/

pdonorio commented 8 years ago

Note: one possible alternative to angularjs (probably the only one, at least to my eyes) is the aurelia framework.

It's (much) simpler to install and configure and launch with nodejs, I just tested it.

It also has a cool integration with material design lite thanks to this plugin.

Since yesterday I tried to start an angular2 project and felt bad as 2 years ago when trying yoeman and grunt, we might really understand the risks of angular2.

In the meanwhile we should really exploit the angularjs1.5+ component as an alternative on starting to write our own custom tags.

pdonorio commented 8 years ago

While on vacation I was reading here and there a lot of people complaining about the direction that angularjs2 is taking comparing to how the javascript developers took.

So React is the other way aroung. Based on this interesting article:

"For the long term, I, personally, would choose React, using Redux architecture, Axios for promise-ready HTTP requests and react-router. "

Uhm. Don't know. I'll keep adding notes here to take a better decision at the end of the year.

pdonorio commented 7 years ago

It's easier https://codequs.com/p/BksMQsdWj/why-angular2-is-easier-than-angularjs but yet the compile problem is very heavy

pdonorio commented 7 years ago

An approach in the middle: move towards how React work, but keeping using angularjs1.

To do so, we can interact with Redux. See this tutorial with ngRedux to get the sense of how redux works.

The syntax is a little bit different. In fact files and packages are imported python-like, with a bundler. This means getting back to gulp&browserify; using nodejs to serve files in development for the frontend... If we want to test it, see here.

Note: inspired by this tweet

pdonorio commented 7 years ago

More info to migrate to angularjs2 from 1: https://www.angular2patterns.com/

pdonorio commented 7 years ago

Another great resource for migration, by our friend Todd http://ngmigrate.telerik.com/

pdonorio commented 7 years ago

Un interessante componente "auth0" a costo nullo per gli sviluppatori, che funzionerebbe su angular1 e 2 https://auth0.com/blog/angular-2-authentication/

pdonorio commented 7 years ago

So what's the problems with frontend development? This article sums it up, on a JS point of view.

At the very minimum in this issue we should somehow not forget that in JS we must keep in mind that simpler is better.

So should we consider as another option going to move to something more close to plain vanilla JS? Some example are vue or elm.

Or: should I stop working on frontend development?

pdonorio commented 7 years ago

In this discussion, writing clear angularjs, and use that MVC pattern to its best, is a key point. Somebody wrote about it: https://www.simple-talk.com/dotnet/net-development/4-keys-clean-angular-implementation

Basically it tells developers to use functions instead of expressions, variables and code in the View. I almost agree, the problem is about the digest cycle evaluation and performances when doing so.

pdonorio commented 7 years ago

In case of getting better with angularjs 1.x, here's what to read.

pdonorio commented 7 years ago

So reading the latest from todd I have the feeling that angularjs1 won't be enough for us. Since react doesn't even have routing and we rely a lot on that, the last thing to check to understand if we need angularjs2 is a prototyping example to create two similar controllers.

Maybe @mdantonio can think of this example and I can create a nodejs container to test it.