angularfire: Key X was undefined. Cannot pass undefined in JSON. Use null instead.

I get this error when I delete all the text in the input field. It seems that when the input field is empty, the property “name” on the object “user” is set to undefined instead of null.

View:

<input type="text" ng-model="user.name">

Controller:

var firebaseio = new Firebase(FIREBASE_URL);
$firebase(firebaseio.child(USER_PATH)).$asObject().$bindTo($scope, "user");

So, how can I set it to null when the input field is cleared?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 21 (4 by maintainers)

Most upvoted comments

@semeano after applying novalidate to the form element, I’m still getting an error. You can see the same result on my jsfiddle at https://jsfiddle.net/kkwo9h5n/6/. Any suggestions on how else I can validate a required field and make firebase work?