From 80341cb9badd952fdc80094df4123629313b4cc4 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 1 May 2013 20:55:25 -0400 Subject: feat(injector): add has method for querying Closes #2556 --- src/ng/animation.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/ng/animation.js') diff --git a/src/ng/animation.js b/src/ng/animation.js index 9a5a5a95..76cf943e 100644 --- a/src/ng/animation.js +++ b/src/ng/animation.js @@ -51,13 +51,9 @@ function $AnimationProvider($provide) { */ return function $animation(name) { if (name) { - try { - return $injector.get(camelCase(name) + suffix); - } catch (e) { - //TODO(misko): this is a hack! we should have a better way to test if the injector has a given key. - // The issue is that the animations are optional, and if not present they should be silently ignored. - // The proper way to fix this is to add API onto the injector so that we can ask to see if a given - // animation is supported. + var animationName = camelCase(name) + suffix; + if ($injector.has(animationName)) { + return $injector.get(animationName); } } } -- cgit v1.2.3