I want to make an error if the initialization fails in Angular.js.

Asked 2 years ago, Updated 2 years ago, 105 views

I am using Angular. When accessed from a browser that does not support it, I usually look at UA and play it in a blacklist style, but I would like to make an error for all browsers that do not support it.

So I thought that if the Angular initialization process gets mossy, I should make an error.

Is there a way to detect when Angular fails to initialize?

javascript angularjs

2022-09-30 20:27

1 Answers

Why don't you handle the window.onerror event before initialization and cancel the event with angular.Module.run when initialization is complete?

However, it may be difficult to determine which browser is supported by simply checking if there is an error in the initialization process.(IE8 is detectable during initialization process)but)

There may be cases where initialization works but falls during execution, or some of the features provided by CSS3 and HTML5 are not supported.

So why don't you try Modernizr?

http://www.buildinsider.net/web/modernizr/01

For example, if you want to check if you have EcmaScript 5 features, you can check and download ES5 at http://v3.modernizr.com/download/ and check with the following code:

 if(!Modernizr.es5){
  alert("Not supported browser");
}


2022-09-30 20:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.