André Snede
André Snede

Reputation: 10045

AngularJS is not validating my form

I know Angular pretty well, use it everyday, but apparently, I'm having one of those days..

I'm probably missing something hideously obvious, but why aren't I seeing testForm.testField.$invalid & testForm.testField.$dirty etc???

var myApp = angular.module('myApp',[]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp">
    <form name="testForm">
        <input type="text" name="testField" ng-model="testField" required="required" />
        {{testForm | json}}    
        {{testField}}
    </form>
</div>

Upvotes: 0

Views: 53

Answers (1)

Duncan
Duncan

Reputation: 95652

If you look in the Angular source, the conversion to JSON says:

Properties with leading $ characters will be stripped since angular uses this notation internally.

Unfortunately the documentation for the json filter doesn't mention that.

See https://github.com/gaborcs/angular.js/blob/master/src/Angular.js lines 930-931.

Upvotes: 2

Related Questions