ways to communicate between controllers (services + events)
controllerAs
syntaxdigging-into-angulars-controller-as-syntax
Le principe c'est de ne plus injecter le scope pour travailler dessus mais d'utiliser le controller pour l'interpolation.
En terme d'achi, le controller n'est plus vraiment un controlleur mais prend sa place dans le MVVM en tant que V (associé au HTML)
$scope
$scope
must read$rootScope.Scope
$digest
already in progress issueEvalAsync()
or setTimeOut()
$evalAsync
from a directive, it should run after the DOM has been manipulated by Angular, but before the browser renders$evalAsync
from a controller, it should run before the DOM has been manipulated by Angular (and before the browser renders) -- rarely do you want this$timeout
, it should run after the DOM has been manipulated by Angular, and after the browser renders (which may cause flicker in some cases)$scope
dirty checkingng-model
etc ... set a reference check.