262,559
questions
4501
votes
15
answers
855k
views
"Thinking in AngularJS" if I have a jQuery background? [closed]
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 ...
3425
votes
30
answers
785k
views
AngularJS: Service vs provider vs factory
What are the differences between a Service, Provider and Factory in AngularJS?
2051
votes
14
answers
359k
views
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 ...
1318
votes
20
answers
672k
views
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.
1204
votes
23
answers
782k
views
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 ...
1132
votes
6
answers
1.0m
views
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 ...
1115
votes
15
answers
271k
views
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-...
1111
votes
18
answers
570k
views
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:
<pane bi-title="...
1082
votes
9
answers
348k
views
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 ...
1055
votes
7
answers
311k
views
'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) {
...
1051
votes
3
answers
157k
views
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 ...
908
votes
12
answers
622k
views
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) {
...
867
votes
28
answers
468k
views
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 ...
836
votes
17
answers
702k
views
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: ...
774
votes
33
answers
651k
views
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 <input> inside this Modal.
Every time <input&...