What is Angular JS
AngularJS is a relatively new JavaScript framework by Google, designed to make your front-end development as easy as possible. You know the best part? It’s all done in pure JavaScript and HTML. No need to learn another new programming or templating language.
Why It's Called “AngularJS”
Now a question comes to our mind that why the frame work is named as “AngularJS”?
Well, because the namespace is “ng
” and “ng
” sounds like “Angular” (HTML has Angular brackets).
Why Use AngularJS
1. MVC done right
Most frameworks implement MVC by asking us to split the app into MVC components, then we require to write code to string them up together again. But in case of Angular, MVC is implemented by splitting the app into MVC components, then just let Angular do the rest. Angular manages your components for you and also serves as the pipeline that connects them.
2. Two-Way Data Binding
Two-way binding is the coolest concept in AngularJS. It's a fascinating real-time concept. Just like desktop application, mobile apps user also wishes to witness swift changes in the UI. So AngularJS’ two-way data binding handles the synchronization between the DOM and the model, and vice versa. As a result, the UI changes based on other input components are very much smooth without any extra effort on the part of the developer.
3. Uses POJO Data Models
Data models in Angular are plain old JavaScript objects (POJO), so you no longer need the getter/setter functions.
Add or change properties directly on it and loop over objects and arrays. This makes code look clean and intuitive.
4. Customized Directives
Directives can create custom HTML tags that serve as new and custom widgets.
Directives achieve this by allowing users to invent their own HTML elements. Putting DOM manipulation code into the directives makes it easy for the users to separate them out of MVC app and leaves MVC to update the view with new data, but how the view will behave is certainly up to directives.
5. Easy Adjustable Filters
Filters help to clean the data and involves in something simple, such as:
- Formatting decimal places
- Reversing the order of an array
- Filtering an array based on certain parameter
- Making changes in pagination
6. AngularJS requires less coding
The data-binding feature allows developers to stop providing data manually into the view. Filters allow you to manipulate the data on the view level without changing your controllers. As a result, developers need to write very little code to achieve the task, which is a great deal for the developers.
7. Built-In Dependency Injection
AngularJS has a built-in dependency injection subsystem useful for developers as it makes application development easier including testing. Dependency Injection (DI) allows users to ask for dependencies, rather than having to go and look for them or make them on their own.
Say for example, “Hey I need X’, and the DI is responsible for creating and providing it for you. If user wants to gain access to core AngularJS services, all they need to do is add service as a parameter. AngularJS will detect that users need that service and will provide it instantly.
When to Use Angular JS
AngularJS is a very good SPA framework. If we want to create a SPA application, then AngularJS is a good option for it.
Now a question comes to mind: ”What the hell is this SPA?”. Okay, there is no need to panic, let me explain it to you.
“SPA” refers to Single Page Application. A Single Page Application is one in which we have a shell page and we can load multiple views into that. So a traditional app, as you know you typically blink and load everything again.
It’s not very efficient on the bandwidth, especially in the mobile world. In a SPA, we can load the initial content upfront and then the different views or the small kind of mini web pages can be loaded on the fly and embedded into the shell.
CodeProject