Learn AngularJS
AngularJS is a JavaScript framework, released by Google in 2010, that lets you extend HTML with new attributes to build dynamic web applications.
What Is AngularJS?
AngularJS is a JavaScript framework, first released by Google in 2010, that lets you extend plain HTML with new attributes called directives. It was built to make it easier to develop dynamic, single-page web applications directly in the browser, without needing a build step or compiler.
- Extends HTML with custom attributes (ng-app, ng-model, ng-repeat, and more)
- Adds two-way data binding between the HTML view and plain JavaScript data
- Organizes code into modules using angular.module(...)
- Uses controllers and $scope to hold and manipulate application data
- Runs entirely as plain JavaScript loaded with a single <script> tag
A First Look
An AngularJS application starts with the ng-app directive, which tells AngularJS which part of the page it should control. Inside that region, you can bind data with ng-model and display it with double curly braces.
Example
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<body>
<div ng-app="">
<p>Name: <input type="text" ng-model="name"></p>
<p>Hello {{ name }}!</p>
</div>
</body>
</html>As soon as the page loads, AngularJS scans the HTML for directives like ng-app and ng-model and activates them. Typing into the input box updates the name variable, and the {{ name }} expression re-renders automatically — no manual DOM manipulation is required.
Why AngularJS Mattered
AngularJS popularized ideas — declarative templates, two-way binding, dependency injection — that shaped a generation of JavaScript frameworks. Many production systems built between 2010 and 2018 still run on it, so knowing how ng-app, $scope, and directives fit together is useful for maintaining that code.
Exercise: AngularJS Introduction
What is AngularJS primarily used for?
Frequently Asked Questions
- Should I still learn AngularJS?
- Only to maintain something that already exists. AngularJS reached end of life in January 2022 and receives no security patches. If you are choosing a first framework, learn Angular, React or Vue instead; the underlying concepts transfer even though the syntax does not.
- What is the difference between AngularJS and Angular?
- AngularJS is version 1, written in JavaScript using scopes, controllers and two-way binding. Angular is a complete rewrite from version 2 onward, built in TypeScript around components. They are separate frameworks, and migrating between them is a rewrite rather than an upgrade.
- Is AngularJS the same thing as JavaScript?
- No. JavaScript is the language the browser runs; AngularJS is a framework written in that language. You need working JavaScript knowledge first, because every AngularJS controller, service and directive you write is ordinary JavaScript underneath.