"AdMob not is not defined". Baffled

I don’t understand why I’m getting this problem. This is my code:

var admobid = {};
if( /(android)/i.test(navigator.userAgent) ) { // for android
  admobid = {
      banner: 'ca-app-pub-xxxx,
      interstitial: 'ca-app-pub-yyyy'
  };
 } else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { // for ios
  admobid = {
      banner: 'ca-app-pub-xxxx',
      interstitial: 'ca-app-pub-yyyy'
  };

}

if(typeof AdMob !== "undefined") AdMob.createBanner( {
adId: admobid.banner, 
position: AdMob.AD_POSITION.TOP_CENTER, 
autoShow: true } );
else alert("Admob is not defined");

I just don’t see why I’m getting the not defined error. I’m using my own AdMob references obviously. And I am testing it on an Android phone.

Any ideas?

Do you have added ngCordova module to your app? Maybe you miss adSize configuration? (I don’t remember if you must specify dimensions).

I have ngCordova added, yes.

I haven’t read anything, at all, about adSize configuration, nor have I seen it in the docs. If it’s needed that is huge and utterly ridiculous omission from the docs.

It’s working now.

See this question for what (I think) was wrong: Code has stopped running from inside .run, or at least some of it has