Fix errors in older AngularJS versions (tested against Plunker, using AngularJS v1.1.5)