As mentioned in the comments, data binding will not “fail” by itself when an attribute is not defined in scope, but will create this attribute in the scope transparently.
If you need some kind of notification behavior when the name is not found, you can get it manually by decorating the ng-model directive to check if its value is defined in the area at the time it is inserted into the DOM.
.config(['$provide', function($provide) { $provide.decorator('ngModelDirective', ['$delegate', function($delegate){ var directive = $delegate[0];
This will check the definition of the ng-model value in the controller area and a warning if it is not set.
Check out the working jsfiddle on how this might spell a typo.
I did not test this and did not think about all the scenarios, so it can really be broken somewhere ... I am also not sure how this will concern the search for attrs that are defined in the parent area.
Also, see this nice blog post for a more detailed description of directives.
crennie
source share