Introduction to AngularJS
What is Angular ?
AngularJS is a powerful open source JavaScript framework for web applications. It was originally developed in 2009 by Misko Hevery and Adam Abrons. It is now maintained by Google.
Advantages
- AngularJS allows you to use MVC (Model View Controller), which means you can do a website with one single page, usually the
index.html
file. - AngularJS uses dependency injection.
- Write less code!
- AngularJS can run on every web browsers (Even Internet Explorer!).
Features
-
MVC:
It splits an application intro different parts (Model, View, and Controller) to create a Single Page web Application.
-
Data Binding:
Sync data between the model and the view.
-
Scope:
It’s an object that refers to the application model. The link between controller and view.
-
Controllers:
Functions bound to a specific scope.
-
View:
What the user sees (the DOM).
-
Services:
These are substitutable objects that are wired together using dependency injection. AngularJS come with several built-in services for example $http to make a XMLHttpRequests.
-
Filters:
Format the value of an expression to display a new one. They can be used in view templates, controllers or services.
-
Directives:
Directives are markers on DOM elements (such as elements, attributes, css, and more). These can be used to create custom HTML tags that serve as new, custom widgets. AngularJS has built-in directives (ngBind, ngModel…)
-
Templates:
Templates are written with HTML that contains Angular-specific elements and attributes. Angular combines the template with information from the model and controller to render the dynamic view that a user sees in the browser.
-
Routing:
Way to switch to different views.
Components
The AngularJS framework is divided in 3 main parts:
- ng-app: It defines and links an AngularJS application to HTML.
- ng-model: This directive binds the values of AngularJS application data to HTML input controls.
- ng-bind: This directive binds the AngularJS Application data to HTML tags.