Questions tagged [angularjs]

Use for questions about AngularJS (1.x), the open-source JavaScript framework. Do NOT use this tag for Angular 2 or later versions; instead, use the [angular] tag.

AngularJS is an open-source JavaScript framework for building CRUD-centric Ajax-style web applications. Its goal is to shim the browser to augment the HTML vocabulary with directives useful for building dynamic web applications.

AngularJS ships with directives which add two-way data binding, DOM control and unrolling, code-behind DOM, form validation, and deep linking.

Initially released in 2009, AngularJS was developed and maintained by Google, and is used internally by Google in 1600+ applications.

Note: AngularJS refers to all 1.x versions of the framework, while Version 2 and higher are referred to now as "Angular" (see It's just Angular). The [tag: angular] tag should only be used for questions pertaining to versions 2 and higher.

AngularJS's Philosophy

  • Encourages developers to create their own directives, turning the HTML into a DSL suited to building their kind of application. The result significantly reduces the amount and complexity of JavaScript needed to build web applications.
  • UI is best described in the declarative form (HTML), and that behavior is best described in an imperative form (JavaScript) and that the two should never meet.
  • Encourages developers to design their client architecture using advanced software principles like dependency injection (DI), separation of concerns (SoC), testability, and a file structure.

Notable features

  • Teach your browser new tricks by adding behavior to HTML tags/attributes
  • Controllers provide code-behind DOM with clear separation from the view
  • Two-way data binding without the need to extend or wrap the model objects
  • Dependency injection assembles the application without 'main' method
  • Promises/futures remove many callbacks from code when communicating with the server
  • Directives
  • Views and routes
  • Filters
  • Form validation
  • Strong focus on testability
  • Extend HTML with your own behavior
  • Angular uses spinal-case for its custom attributes and camelCase for the corresponding directives which implement them

Versions

Notable AngularJS versions, code names, and release dates include:

Version Code Name Release Date
AngularJS 1.0.0 temporal-domination June 6, 2012
AngularJS 1.1.0 increase-gravatas August 31, 2012
AngularJS 1.2.0 timely-delivery November 8, 2013
AngularJS 1.3.0 superluminal-nudge October 13, 2014
AngularJS 1.4.0 jaracimrman-existence May 26, 2015
AngularJS 1.5.0 ennoblement-facilitation February 5, 2016
AngularJS 1.6.0 rainbow-tsunami December 8, 2016
AngularJS 1.7.0 nonexistent-physiology May 11, 2018
AngularJS 1.8.0 nested-vaccination June 01, 2020

Latest Stable Version:

Version Code Name Release Date
AngularJS 1.8.2 meteoric-mining October 21, 2020

Actively developed Version:

AngularJS v1.8.x  

For code names, release dates and notes visit the GitHub changelog. To see the latest announcements and AngularJS discussions, visit the official Angular Blog or AngularJS on Gitter

Bits

Community

Asking a question

  • Mention which version of AngularJS you're using
  • Reduce your issue to a small example
  • Explain the behavior you experienced and its difference from your expectations
  • Post a reduced working code on plnkr.co or jsfiddle.net
  • Don't know how? Clone one of these existing jsFiddles

Getting Started

Style Guides

AngularJS UI Libraries

Debugging

Testing

Recent

2014

2013

2012

2011

2010

Video Tutorials

Who is using

Developed by Google

262787 questions
4507
votes
15 answers

"Thinking in AngularJS" if I have a jQuery background?

Suppose I'm familiar with developing client-side applications in jQuery, but now I'd like to start using AngularJS. Can you describe the paradigm shift that is necessary? Here are a few questions that might help you frame an answer: How do I…
Mark Rajcok
  • 362,217
  • 114
  • 495
  • 492
3410
votes
30 answers

AngularJS: Service vs provider vs factory

What are the differences between a Service, Provider and Factory in AngularJS?
2043
votes
14 answers

How does data binding work in AngularJS?

How does data binding work in the AngularJS framework? I haven't found technical details on their site. It's more or less clear how it works when data is propagated from view to model. But how does AngularJS track changes of model properties without…
Pashec
  • 23,199
  • 3
  • 26
  • 26
1311
votes
20 answers

How do I access the $scope variable in browser's console using AngularJS?

I would like to access my $scope variable in Chrome's JavaScript console. How do I do that? I can neither see $scope nor the name of my module myapp in the console as variables.
murtaza52
  • 46,887
  • 28
  • 84
  • 120
1204
votes
23 answers

What is the best way to conditionally apply a class?

Lets say you have an array that is rendered in a ul with an li for each element and a property on the controller called selectedIndex. What would be the best way to add a class to the li with the index selectedIndex in AngularJS? I am currently…
respectTheCode
  • 42,348
  • 18
  • 73
  • 86
1126
votes
6 answers

How do I use $scope.$watch and $scope.$apply in AngularJS?

I don't understand how to use $scope.$watch and $scope.$apply. The official documentation isn't helpful. What I don't understand specifically: Are they connected to the DOM? How can I update DOM changes to the model? What is the connection point…
ilyo
  • 35,851
  • 46
  • 106
  • 159
1111
votes
15 answers

What is the difference between angular-route and angular-ui-router?

I'm planning to use AngularJS in my big applications. I'm in the process to find out the right modules to use. What is the difference between ngRoute (angular-route.js) and ui-router (angular-ui-router.js) modules? In many articles when ngRoute is…
1106
votes
18 answers

What is the difference between '@' and '=' in directive scope in AngularJS?

I've read the AngularJS documentation on the topic carefully, and then fiddled around with a directive. Here's the fiddle. And here are some relevant snippets: From the HTML: {{text}} From the pane…
iwein
  • 25,788
  • 10
  • 70
  • 111
1081
votes
9 answers

angular.service vs angular.factory

I have seen both angular.factory() and angular.service() used to declare services; however, I cannot find angular.service anywhere in official documentation. What is the difference between the two methods? Which should be used for what (assuming…
Jakob Jingleheimer
  • 30,952
  • 27
  • 76
  • 126
1054
votes
3 answers

What are the nuances of scope prototypal / prototypical inheritance in AngularJS?

The API Reference Scope page says: A scope can inherit from a parent scope. The Developer Guide Scope page says: A scope (prototypically) inherits properties from its parent scope. So, does a child scope always prototypically inherit from its…
Mark Rajcok
  • 362,217
  • 114
  • 495
  • 492
1054
votes
7 answers

'this' vs $scope in AngularJS controllers

In the "Create Components" section of AngularJS's homepage, there is this example: controller: function($scope, $element) { var panes = $scope.panes = []; $scope.select = function(pane) { angular.forEach(panes, function(pane) { …
Alexei Boronine
  • 11,061
  • 4
  • 19
  • 14
906
votes
12 answers

Working with $scope.$emit and $scope.$on

How can I send my $scope object from one controller to another using .$emit and .$on methods? function firstCtrl($scope) { $scope.$emit('someEvent', [1,2,3]); } function secondCtrl($scope) { $scope.$on('someEvent', function(mass) {…
Paul Kononenko
  • 9,407
  • 4
  • 18
  • 13
866
votes
28 answers

AngularJS : Prevent error $digest already in progress when calling $scope.$apply()

I'm finding that I need to update my page to my scope manually more and more since building an application in angular. The only way I know of to do this is to call $apply() from the scope of my controllers and directives. The problem with this is…
Lightbulb1
  • 12,882
  • 6
  • 22
  • 23
836
votes
17 answers

Insert HTML into view from AngularJS controller

Is it possible to create an HTML fragment in an AngularJS controller and have this HTML shown in the view? This comes from a requirement to turn an inconsistent JSON blob into a nested list of id: value pairs. Therefore the HTML is created in the…
Swaff
  • 13,548
  • 4
  • 26
  • 26
774
votes
33 answers

How to set focus on input field?

What is the 'Angular way' to set focus on input field in AngularJS? More specific requirements: When a Modal is opened, set focus on a predefined inside this Modal. Every time becomes visible (e.g. by clicking some button), set…
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
1
2 3
99 100