AngularJS is one of the powerful frameworks that helps in creating dynamic apps. It is GitHub’s third-largest starred repository.
In fact, many popular web applications, including Netflix, PayPal, YouTube for PS3 are currently using it.
However, AngularJS environment setup is often tricky and it needs AngularJS Library, editor, browser, web server.
At 1 onlyhost , we often get requests from our customers to set up AngularJS environment as part of our Server Management Services.
Today, we’ll see how our Support Engineers set up AngularJS environment fix related errors.
Importance of AngularJS
Before proceeding further, let’s get an insight on the importance of AngularJS.
AngularJS is a single-page framework for dynamic web apps. AngularJS, developed by Google gain its popularity due to its key features.
The features that make it a popular choice among others are:
- Model-View-Controller: Angular.js works on a modern design pattern. This pattern splits the business logic layer, the data layer, and presentation layer into a separate sections. As a result, the management of separate layers would become easy for app developers.
- Data Model Binding: This is again a boon to developers. There comes no need to write special code to bind data to the HTML controls
- Predefined codes: Angular makes much of the code and they are readily available.
Moreover, there are fewer errors associated with this frame. Angular.js will automatically keep the data in the HTML code and the data layer in sync. In addition to this, it support various testing modes like Unit Testing, Integration Testing, etc.
On the whole, it comes really handy for web app developers.
Setup AngularJS Development Environment
Now, let’s see how our Support Engineers set up a development environment for AngularJSby using following tools.
1. AngularJS Library
We go to angularjs.org and download the AngularJS library.
2. Editor
AngularJS is a HTML and JavaScript code. So, we install any editor/IDE as per customer choice. Again, the popular editors include:
- Visual Studio
- Sublime Text
- Aptana Studio 3
Here, this gives users a flexibility to choose the editor of their choice.
3. Browser
Fortunately, AngularJS is compatible with any web browsers like Google, Firefox, etc.
4. Web server
Finally, AngularJS apps need a web server to process data. Therefore, we use web servers like Apache, IIS, etc. to set up AngularJS environment.
Top errors in AngularJS environment
From our experience in managing servers, we often see developers facing problems with AngularJS environment setup.
Let’s now take a look on how our Dedicated Engineers deal with them.
1. Incorrect program path
Often, wrong program path create problems with AngularJS applications. For the proper working of the app, the program should exist at the declared PATH. And, if it is missing, it will throw up errors.
For example, when a customer tried to run ‘ng‘ command after installing angular-cli, received the below error:
-bash: ng: command not found
Here, this happened as the program was missing in the expected location. Therefore, to fix the error, we had to add an alias in the user’s bash_profile settings.
Again, the same error can happen due to broken npm package or failed installation. In such cases, our Dedicated Engineers reinstall the packages and fix the problem.
2. Module unavailable error
Similarly, when using a new directive in AngularJS code, it often shows up Module unavailable errors too. Unfortunately, it displays a totally non intuitive error message. And, this make troubleshooting even tougher.
For instance, a sample error when app fails to start looks like:
Error: [$injector:modulerr] Failed to instantiate module ngModall due to:
Error: [$injector:nomod] Module ‘ngModall’ is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
In most cases, this happens when users don’t add the correct module name to the dependency list or misspell it. Occasionally, this can show up when they don’t add the javascript to the index file too.
Therefore, we fixed it by adding the directive to the list of dependency modules. Additionally, we added links to the java-script files and css that the directive uses.
[Developing an app and need to setup AngularJS environment? We can install it for you.]
Conclusion
In short, creating dynamic web pages based on AngularJS has become popular. This need a proper environment. Today, we saw how our Dedicated Engineers setup AngularJS environment and fix errors with it.