Fixed IE8 + angular issue which causes a stack overflow. Fixes #2940

Pull request to fix #2940 for your convenience