angularjs - angular child scope can not refer to parent -
i new angular , try figure out how scope works.
i assume child scope inherit scope parent. see angularjs wiki
in angularjs, child scope prototypically inherits parent scope.
so create simple test code in pluncker
but when change scope variable child scope, not reflect change parent scope?
why it? did wrong?
scopes inherit property parent when property is missing. in code, when don't type yet, property missing , inherited parent scope, start typing, property created on child scope a separate property. after creating property on child scope, ng-model
keeps updating property on child scope.
in case need bind parent scope's properties, try $parent.out_var1
:
<input type="text" ng-model="$parent.out_var1">
Comments
Post a Comment