Sniphs
Sniphs

Reputation: 35

Why not use only two way data binding?

Why shouldn't I use two way data binding all the time?

Upvotes: 0

Views: 1617

Answers (2)

Martin Cremer
Martin Cremer

Reputation: 5572

In a nutshell: Angular's change detection goes perfectly hand in hand with immutability of objects, but two-way data binding mutates objects.

Upvotes: 0

Arda Suğur
Arda Suğur

Reputation: 36

When you're first starting angular, it's ok to use 2 way binding. But it got some disadvantages.

First things comes to my mind are: It's template driven what that means is: you can't dynamically add or remove data to bind. You have'll to define all data fields at HTML and then hide or show them.

Second is angular has change dedection cycle running behind the veils. It constantly checks if anything changed so it can update its counterpart. When you application is growing bigger and bigger, this performance load is adds up. And then you have to optimize.

As I say, as a newcomer, you can use it. But you'll experience why you should use one way bindings and the other ways of angular yourself.

Upvotes: 1

Related Questions