Why does it seem ng-if detaches from scope?

angularjs

Solution

`ng-if` creates a new child scope, thus you're editing the model in the child scope instead of the original one. If you change it to `$parent.name` it works just fine.

And here's the reasoning behind it by one of the guys from the Angular team:

The reason why ng-switch creates a new scope, is that scope is used for memory management.

When the switch branch is removed we need to remove all of the bindings as well as all of the click listeners. This is all done through scope.

To put it differently whenever DOM structure changes, a new scope needs to be created, so that we can properly clean up after ourselves.

https://groups.google.com/forum/#!searchin/angular/why$20does$20ng-switch/angular/n_PlBtwemJg/kk6me3JdE88J

Problem

It seems that ng-if is detaching input from scope? Or am I just doing something wrong? when using: ``` <input ng-if="1===1" ng-model="name"> ``` changes in input don't affect the scope. When I remove the ng-if it works! What is that? attached pluncker

Original source