AngularJS Basics Notes
AngularJS Basics Notes
Introduction to AngularJS
single-page applications (SPA). Its architecture is MVC (Model-View-Controller), which separates the
To set up AngularJS, include the AngularJS library using a CDN or download it. Use any text editor (like VS
Create an HTML file and link the AngularJS script. Define the Angular module and controller. Use
Expressions are used to bind data to HTML. Modules are containers for the application parts like controllers
and services.
- AngularJS Directives:
Directives extend HTML by adding new attributes or tags. Common directives include ng-model, ng-bind,
- AngularJS Controllers:
Controllers are JavaScript functions that control the data of AngularJS applications. They are defined using
ng-controller directive.
Controllers are created using the .controller() method. Inside the controller, the $scope object is used to bind
Services are reusable components used to share data and functionality across the application.
Services can be created using .service() or .factory(). They help in separating the business logic from the
controller.
It is the synchronization between the model and the view. Any change in the model updates the view and
vice versa.
With two-way binding, the UI reflects changes in the model instantly using ng-model.
Canva Basics - Prepared Notes
- AngularJS Scopes:
Scope is an object that refers to the application model. It acts as a glue between the controller and the view.
Filters are used to format data displayed to the user. Examples include currency, date, filter, and orderBy.
$http service is used to make AJAX calls. Data retrieved can be displayed in tables using ng-repeat and
filters.
Forms can be created using standard HTML form elements and AngularJS directives like ng-model,
ng-required. AngularJS provides real-time validation and error handling using form states like $valid, $dirty,
and $touched.
Define templates and controllers for each route to enable page navigation without reloading.
Canva Basics - Prepared Notes
Nested routes allow loading different views in a layout. Route parameters help in passing data between
routes.
Advanced Topics
- AngularJS API:
The AngularJS API provides a rich set of built-in services, directives, filters, and testing tools.
AngularJS supports CSS-based animations using ngAnimate module for transitions like enter, leave, and
move.
- AngularJS Application:
A complete AngularJS application involves modules, controllers, views, services, routing, and data binding