Source code from ng-book (it has an MIT license).