17375 Views | 7 Min Read
1. Keep a track on the count of Watchers
Angular JS creates a watcher for every binding. Evaluation and comparison for previous bindings are done at each digest phase. In the end, the number of watchers comes out to be huge. Few watchers are okay but these watchers start getting troublesome when there are hundreds and thousands of them in the code eventually slowing down the performance of an application in the browser. Angular JS community has a standard Global maximum limit of 2,000 watchers, so it’s better to keep track of the count of watchers from the very beginning of development. Some developers can write the code which counts watchers and thus helping in modifying and optimizing the code later.
2. Inability To Use The Available Tools
Most of the developers do not utilize the available tools to their best extent. This is one of the most disappointing circumstances since it becomes necessary to utilise a tool sooner or later. For instance, Firefox and Chrome incorporate uncommon improvement strings that involve investigation, mistake yield and profiling. With the help of these instruments, a developer can discover the errors quickly and save a lot of time.
3. Not Compartmentalizing Properly
Compartmentalizing your code is the core part of coding in Angular JS. When you work with MVC, the general concept is that you have a controller for a view. The controller is your rationale layer, and it’s imperative that inside this layer you make compact compartments for each area of your application. A typical oversight is to put the excessive concept into one controller. On the off chance that you have to separate your layer for your application to make sense, don’t take alternate routes. Rather, make smaller sorted out units for your logic layer.
Code organization is one of the most crucial parts of application building. It won’t seem of much importance initially but when you have a team of developers working on the same project, it’s easier to work on, find errors and develop smaller parts individually. A well-organised code makes the application adaptable for development, which helps as the organisation grows.
4. Falling Back Into jQuery
jQuery is a customary library for handling events and for making DOM Manipulations easier. However, AngularJS, on the other hand, is a framework that is used for the creation of scalable applications, testing and development of applications and hence it cannot be utilised in the amplification of HTML documents. Angular JS possess an ample amount of features and so, a developer should know about all the available features before involving jQuery in the development. Even if you need DOM manipulations, it doesn’t necessarily mean that you have to use jQuery.
5. Improper Use Of Event Handlers
Angular’s horizon is seized to hold all the data that is required to show all the content of the page to the user. It is quite affable that permits writing of custom functions based upon the crowded content. Angular JS can be perfect specifically when it comes to appending functionality grounded on forecasted data like boasting a button based on user input. However, this rebels with one of the basic principles of the Angular JS which is to keep all the logic and display sorted.
6. As an Angular JS Developer you Forget To Test
It’s quite handy for the developers to compile and execute an application on their individual machines and presuming that it goes well with every other system out there. Not testing an application before their release is a common mistake among developers because they don’t understand the fact that different environments can instigate bugs.
You don’t need to acquire an environment with every operating system, rather you should test your application using popular cross browser testing tools like LambdaTest. LambdaTest is a budding startup and a popular online tool that gives you real time access to 2000+ browsers and a lot of operating systems online. You can easily perform live interactive cross browser testing using LambdaTest and even capture automated screenshots for accelerated web layout testing. It can also help you test your locally hosted pages so that you don’t have to wait till the end to fix the bugs!
7. Fail to Utilize Batarang
Batarang is an extraordinary Google Chrome extension which is employed for debugging and developing Angular JS applications. Batarang can be useful when operating on abstracting scopes where arguments are limited. Avoid the common mistake of not utilizing this tool to its full potential.
8. Fixed Scope Binding
Normally, Angular accompanies its very own degree settling rules. A simple usage of information sources limit to a model, for example, it can prompt a typical breakdown in the binding system. However, the complexities come down to making sure that the names are fully upskilled. Non-primitives in AngularJS are passed by references whereas primitives are passed by value. To bring this problem to an end, the developer needs to assemble their scope objects properly.
9. As an Angular JS Developer you forget to Unsubscribe
There are two scenarios where unsubscribing grows into a major risk – First, you ignite the lifecycle hook by yourself if it’s a service that you’ve subscription of and second, you stimulate the OnDestroy lifecycle hook if it’s in a constituent that you’ve subscribed. Keep a check on these to avoid any complications later.
10. Declaring Everything With Anonymous Functions
Assigning your functions and objects accounts for a tidy and maintainable code. This kind of well-maintained and documented code is easy to work with and can easily be divided into files. Not just this, such pieces of code have an increased testability. This makes it easy for the developer to maintain the application code and gives more expressibility to the code.
11. Direct Manipulation of DOM
This is the most common mistake that every new Angular JS developer commits. Whether it involves rendering SVG or refreshing a web page’s heading on a context changes, a developer decides to take the easy way out and makes changes to the DOM directly. Never should you be tempted to alter the DOM directly.
12. Not Using $applyAsync
Because there is polling contraption to call $digest() in AngularJS, it is just implemented because of the subsisting directives. $applyAsync aids a lot in detaining the expression resolution to the next cycle of $digest(). There is both an automated and manual way to wield $applyAsync.
13. Declaration Of The Same Component In More Than One NgModule
Declaring a component in multiple NGModule-s is one of the most recurrent mistakes among Angular developers that end up throwing an error right at your screen. This error occurs because one needs to mention each component in the scope of its own NgModule. Every component can belong to only one NgModule. In case you want to make use of any component, the current NgModule must know about it.
AngularJS is an exceptional front-end framework. It’s one of the leading tools on the web for creating single page applications. And since it is scalable and backed by Google, you get plenty of support and guides to get you started. Developing is not just about writing error-free code, it’s about committing an error once and never repeating it. Instead of embracing the “fail fast, fail often” concept, one needs to learn from the mistakes of other developers and ensure that they rarely fail. At least, due to the same mistake.
Written by Harshit Paul
59045 Views | 42 Min Min Read
78435 Views | 16 Min Min Read
91743 Views | 15 Min Min Read
186873 Views | 17 Min Min Read