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
Note: This tutorial covers AngularJS 1.x — the original framework built around angular.module, ng-* directives, and $scope. It is a different project from modern Angular (2+), which is written in TypeScript and uses components instead of controllers.

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

ConceptWhat It Does
DirectiveAn HTML attribute (ng-*) that adds behavior to an element
ExpressionA {{ }} snippet that outputs a JavaScript-like value
ModuleA container created with angular.module(...) that organizes an app
ControllerA JavaScript function that adds data and logic to $scope
$scopeThe object that links a controller's data to the HTML view

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.

Note: You do not need to install anything to follow this tutorial. Every example loads AngularJS from a CDN with a single <script> tag, so you can copy any code block into an HTML file and open it in a browser.

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.