Angularjs-uncaught Error: [$injector: Modulerr]

Source: Internet
Author: User

I encountered an error like the following when I was experimenting with the configuration and translation of the angularjs-system code:

In the JS programming time will often encounter, XXX is not a function, xxx undefined and so on error, as long as see and write their own code statement related things directly find can locate and solve the problem, but sometimes the front-end throws the error and we write the code seems to have no direct relationship, At this time we need a good analysis, and accumulate some of this aspect of the exception handling experience is very useful.

It has nothing to do with the code we wrote ourselves, we need to look it up, see if we can find some connections and get rid of our problems from these contacts, here is my analysis process:

1: First take a good look at the error message, to see if it is a glance can see through, to find out the code snippets you write, if not, try to click into the framework of the code inside to see if you can find some clues

2: Analysis of the wrong part of the code snippet, to see if you can probably locate the problem, if not, debug debugging code

3: The process of debugging the framework code to observe, to see if you can find and their own sections related to the Code section, is generally the problem caused by this piece, even if it is not too far from the source of the problem

4: Follow the above analysis back to view your code snippet, locate and solve the problem

5: summary

Software development This thing encountered a variety of problems is ordinary but the matter, our ability is also by our ability to solve problems to contrast, for the front-end programming, the problem is generally relatively good positioning, good solution. Here are some of the problems that I often encounter:

5-1:xxx is not a function?

There are various reasons for this type of problem, but in general it is possible to see how XXX is implemented to solve the problem. Either it is not a function, or it is overwritten by another code and then becomes not a function.

5-2:xxx not defined?

This type of problem is due to a variety of formats, similar to the 5-1 solution, look for XXX to see the basic can solve the problem. Either there is no definition, or later becomes a undefined, common in chained calls.

5-3: The browser crashes?

The code is likely to go into a dead loop, execute that code, take a good look, if you do not know, only part of the execution of the corresponding code snippet, and then analyze why into the dead loop, to find the code snippet that causes the problem can basically solve the problem.

5-4: Browser not compatible?

This problem is the front-end development of the big head of a problem, I also more head, also met N many times, who let the browser manufacturers so many, in order to compete for their own additional features or the organization of the specified interface through different ways to achieve, or achieve a difference. This is the specific problem of specific analysis, in addition to the use of the framework, it is best to write the code as suggested by the framework, do not have a variety of code implementation methods, such as: there is the implementation of jquery, but also the implementation of the native DOM, but also the implementation of ANGULARJS. First, the specific problem of the specific analysis, but also to accumulate some browsers for the same functionality of different implementations, add different ways to implement the function code according to different browsers.

5-5: Browser loading speed is slow?

This problem also needs specific analysis, network problems, server problems, the amount of resources and so on are likely to cause such problems, the release of the code to be as light as possible, to undergo compression processing, redundant code, redundant comments, redundant printing, redundant library files, etc. to all remove, Other bad guarantees at least the code itself is guaranteed to be the best.

5-6: A piece of code can also implement a function today that, every few days will not be the spirit?

This is the most puzzling, but this problem also often appear, may be the original did not test, it may be other code changes caused by the modification of other code did not test to this piece is not found in time, it is possible that the library file or the framework file version changes caused by the smoke, See where it changed, causing the change here, to specific analysis of the incident.

5-7: The same piece of code, in this page can implement a function to, paste copy to another page is not?

Here the same must be part of the same, there must be a different place, so it is. May be the context is different, may be the environment is different, may be the operating environment is different, in short find their different places can be positioned to the problem, if the different places are quite many can only use the dichotomy one by one, until the location of the code fragment that caused the problem.

5-8: Code logic problem, the corresponding function can not be implemented?

Press F12 and then find the corresponding code to hit the breakpoint, step by step debugging to see, not standardized code writing method often cause some strange strange problems, such as: A method is often not a head in the end, the middle often call other methods or other global variables, and call this method or variable where there are many places, Or the use of global variables everywhere, as well as the repetition of variable names and method names.

5-9: page elements of the style, position problems, not good to see, not aligned?

This problem often occurs, the same page different browser or the same browser different version or different settings will appear this problem, this is a headache browser compatibility problem, the test when the mainstream browser to try, and then adjust, usually develop good programming habits, Accumulate some of the same styles or functions different implementations of the browser, and then make a judgment in the code and then choose the corresponding method. If you are using a frame, use it as recommended by the framework.

5-10: The function of frame can not be realized?

Write their own code and frame conflict, the common is the code naming repeated results, can only step-by-step troubleshooting, there may be other library file code caused, of course, the probability of this problem appears relatively small, but it is possible, specific events specific analysis.

Angularjs-uncaught Error: [$injector: Modulerr]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.