When using Angular 1.x, you might have a simple form that looks like this:
However, if you ran this code and clicked ‘Save’,
would be undefined.
WTF is going on?
The issue is that
ng-if creates its own scope, so
defined on your usual controller scope.
Fortunately the workaround is simple. Just use the controllerAs syntax, which is generally useful for various other reasons.