AngularJS is Google's original frontend framework (version 1.x) for building dynamic, single-page web applications, first released in 2010. It ties for #16 most-used web framework at roughly 7.2% usage share โ a legacy footprint from years of enterprise adoption rather than new project starts. It's a completely different codebase and architecture from modern Angular (2+): AngularJS uses two-way data binding, `$scope`, and its own dependency-injection system, and while it's now in community/legacy maintenance mode, it still powers a large number of older enterprise applications that haven't been migrated.
AngularJS wires HTML directly to a controller's `$scope` object, and custom directives let you package reusable DOM behavior.
// app.js
var app = angular.module('shopApp', []);
app.controller('CartController', ['$scope', function($scope) {
$scope.items = [{ name: 'Widget', price: 9.99 }];
$scope.total = function() {
return $scope.items.reduce(function(sum, i) {
return sum + i.price;
}, 0);
};
}]);
// a simple reusable directive
app.directive('priceTag', function() {
return {
scope: { amount: '=' },
template: '<span>${{ amount | number:2 }}</span>'
};
});
Legacy projects typically pull AngularJS from a CDN or npm; there is no modern CLI scaffold like Angular's `ng new`.
<!-- quickest way: drop in the CDN script -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.3/angular.min.js"></script>
# or install via npm for a build pipeline
npm install [email protected]