JavaScript Edu Resources. Angular Courses. React Tutorials. Join us!

Two Phases of Angular 2 Applications

  • Angular, by means of change detection, is responsible for reflecting the state of the model in the view.
  • In our example, the rate button gets disabled because you cannot rate the same talk twice.Note, the framework has used change detection and property bindings to execute this phase.In our example we are using global state and immutable data.
  • I will explain why this is important below.Why?Now, when we have understood how we’d separated the two phases, let’s talk about why we did it.PredictabilityFirst, using change detection only for updating the view state limits the number of places where the application model can be changed.
  • You have to know how the model gets updated.In Angular 2, you know that Parent will always be updated before Child, and we also know that a property cannot be updated more than once.Angular 2 makes reasoning about the component easier because it limits the number of ways it can be modified, and makes this modification predictable.PerformanceA big part of the separation is that it allows us to constrain the view state propagation.
  • What if I try to change the application model inside a setter that is invoked by the change detection system?Angular tries to make sure that the setter you define for you component only updates the view state of this component or its children, and not the application model.



Two Phases of Angular Applications – Angular



Comments are closed, but trackbacks and pingbacks are open.