Questions tagged [angularjs-scope]

In AngularJS, a scope is an object that refers to the application model. It is an execution context for expressions.

In AngularJS, a scope is an object that refers to the application model. It is an execution context for expressions. Scopes are arranged in hierarchical structure which mimic the DOM structure of the application. Scopes can watch expressions and propagate events.

All scopes are children of the top level $rootScope using prototypical inheritance. A new child scope is created every time a directive in the DOM is configured to do so.

Common pitfall: using scalar variables on the scope within directives that create a new child scope (such as ng-if, ng-switch, ng-repeat, ng-include, ...) and not being able to reference them, due to the prototypal nature of JavaScript (own copy of variable is created in the child scope).

Useful links

8949 questions
157
votes
10 answers

Angularjs: 'controller as syntax' and $watch

How to subscribe on property change when using controller as syntax? controller('TestCtrl', function ($scope) { this.name = 'Max'; this.changeName = function () { this.name = new Date(); } // not working …
Miron
  • 2,137
  • 3
  • 15
  • 14
139
votes
12 answers

AngularJS access scope from outside js function

I'm trying to see if there's a simple way to access the internal scope of a controller through an external javascript function (completely irrelevant to the target controller) I've seen on a couple of other questions here…
dk123
  • 18,684
  • 20
  • 70
  • 77
135
votes
13 answers

AngularJs: Reload page

PORTAL_NAME I want to reload the page. How can I do this?
user880386
  • 2,737
  • 7
  • 33
  • 41
128
votes
14 answers

Controller not a function, got undefined, while defining controllers globally

I am writing a sample application using angularjs. i got an error mentioned below on chrome browser. Error is Error: [ng:areq] http://errors.angularjs.org/1.3.0-beta.17/ng/areq?p0=ContactController&p1=not%20a%20function%2C%20got%20undefined Which…
yokks
  • 5,683
  • 9
  • 41
  • 48
124
votes
1 answer

How to do two-way filtering in AngularJS?

One of the interesting things AngularJS can do is apply a filter to a particular databinding expression, which is a convenient way to apply, for example, culture-specific currency or date formatting of a model's properties. It is also nice to have…
Jeremy Bell
  • 5,253
  • 5
  • 41
  • 63
118
votes
12 answers

Sending event when AngularJS finished loading

Wondered what's the best way to detect the finish of page loading/bootstrapping, when all directives done compiling/linking. Any event already there? Should I overload the bootstrap function?
Lior
  • 40,466
  • 12
  • 38
  • 40
116
votes
10 answers

Get value when selected ng-option changes

I have in my .html page a dropdown list, Dropdown: