Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if angular is loaded correctly

Tags:

Let's say that I want to reference angularjs from a CDN but I would also like a fallback in case the call to the CDN fails, e.g. pointing to a local js-file. When it comes to JQuery I have seen examples where you would do something like this in javascript:

if(typeof jQuery == 'undefined') {
    ....
}

Is there anything similar for angularjs I can do?

like image 482
Stig Perez Avatar asked Nov 02 '13 13:11

Stig Perez


People also ask

How do I know if angular is loaded?

If you get the message Object {version: Object, callbacks: Object} , angular is loaded. If you get the message Uncaught ReferenceError: angular is not defined , angular is not loaded.

How do I know if angular is running in prod mode?

Simply check the production variable present in the environment file, it will be true for production mode and false for development. Show activity on this post. import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' import { enableProdMode } from '@angular/core'; import { AppModule } from './app.


1 Answers

if(typeof angular == 'undefined') {
    ....
}
like image 73
Doron Segal Avatar answered Sep 23 '22 21:09

Doron Segal