Why does Angular read $scope more than needed?

后端 未结 2 968
南笙
南笙 2021-01-27 06:59

I noticed that Angular is less-than-conservative when it comes to reading $scope properties. When the app/controller first instantiate, each bound property defined in the model

2条回答
  •  长情又很酷
    2021-01-27 07:23

    Try catch stack by firebug but it seem (as I know the angular) that it's from $watch implementation - it must firstly evaluate current hash of object to start "listen" to it's changes. So first reading of object is internal checking and second is for view. Not sure, but it have to read objects twice to implement $watch magic.

提交回复
热议问题