AngularJS
Scope & Controller
Gias Kay Lee
Scope in AngularJS
is a plain old Javascript object
$scope
{
$$childHead: Child
$$childTail: Child
$$listeners: Object
$$nextSibling: Child
$$prevSibling: null
$$watchers: Array[2]
$id: '004'
$parent: Child
...
}
Each
Controller Instance
has its own Scope
The properties of a Scope is the
corresponding Controller's
Model
And the
View Template
knows nothing about the Controller
...except those
exposed through the Scope
Kinda Like a ViewModel
Let's see some examples!
Demo #1
Scope & Controller
Demo #2
ngRepeat
Demo #3
ngModel
Demo #4
Controller Instance
Demo #5
Prototypal Inheritance
of
Scopes
Demo #6
The Problem
with
Primitive Types
Demo #7
Passing Value
by
Reference
Demo #8
"Controller as" Syntax
Questions?
Homework
AngularJS: Scope and Controller
By G. Kay Lee
AngularJS: Scope and Controller
- 7,412