SIGN IN SIGN UP
angular / angular.js UNCLAIMED

AngularJS - HTML enhanced for web apps!

0 0 0 JavaScript

perf(form, ngModel): change controllers to use prototype methods

This makes the largetable-bp ng-model benchmarks 10-15% faster (down 90-100ms for me). The actual controller instantiation doesn't change too much but the overall numbers seem consistently faster, I assume all due to reducing memory usage / gc. Specifically on creation there is ~40% less memory GCed, on destruction there is about ~25% less.

PR (#13286)

BREAKING CHANGE:
The use of prototype methods instead of new methods per instance removes the ability to pass 
NgModelController and FormController methods without context.

For example

`$scope.$watch('something', myNgModelCtrl.$render)`

will no longer work because the `$render` method is passed without any context. 
This must now be replaced with

```
$scope.$watch('something', function() {
  myNgModelCtrl.$render();
})
```

or possibly by using `Function.prototype.bind` or `angular.bind`.
J
Jason Bedard committed
9e24e774a558143b3478536911a3a4c1714564ba
Parent: 21e4db9
Committed by Martin Staffa <mjstaffa@googlemail.com> on 9/14/2016, 8:21:09 PM