Friday, 23 November 2018

AngularJS - Which scope is better performance wise? Object.key or Some Variable?

Let's say I have to store customer information, and to manage two-way binding I'll use $scope here. So my doubt here is, which approach is better?

$scope.firstname = "foo";
$scope.lastname = "bar";
$scope.cellno = "1234567890";
$scope.email = "foobar@example.com";

OR

$scope.customerDetailsObj = {};
$scope.customerDetailsObj.firstname = "foo";
$scope.customerDetailsObj.lastname = "bar";
$scope.customerDetailsObj.cellno = "1234567890";
$scope.customerDetailsObj.email = "foobar@example.com";`

I've been wondering about this because I have a large angular application and sometimes the scope watchers count goes beyond 1500. I'm using a chrome extension to see watchers count.

Please share your views. Thank You.



from AngularJS - Which scope is better performance wise? Object.key or Some Variable?

No comments:

Post a Comment