Description
$scope.schema = {
"$schema" : "STANDARD SCHEMA",
"title" : "Schema Title",
"description" : "Schema Description",
"id" : "Schema Id",
"type" : "object",
"properties" : {
"name" : {
"type" : "string",
"title" : "Name",
"description" : "Enter your full name"
}
}
};
$scope.form = [
{
"key" : "name"
}
];
$scope.model = {};
$scope.handleForm = function(myForm){
//myForm is the ngFormController
if(myForm.name.$viewValue === "Ajay"){
$scope.$broadcast("schemaForm.error.name", "invalidName", "Invalid name");
}
else{
$scope.$broadcast("schemaForm.error.name", "invalidName", true);
}
console.log("Model Errors :: ", myForm.name.$error);
console.log("View Value :: ",myForm.name.$viewValue);
console.log("Model value :: ",$scope.model);
console.log("");
}
Hi,
I've found a bug in schema form.
User enters "Ajay" and clicks the submit button which calls the handleForm function on the scope. The handleForm function takes one argument, the ngFormController.
console output :
Model Errors :: Object {invalidName: true}
View Value :: Ajay
Model value :: Object {name: "Ajay"}
The field is invalid and the model has one error {invalidName: true}. Now, the user enters "Ajay U" and clicks the submit button.
console output :
Model Errors :: Object {schemaForm: true}
View Value :: Ajay U
Model value :: Object {name: undefined}
As you can see, the field is invalid and the model value is undefined and has an error {schemaForm: true}.
I'm confused :/ Is it a bug or am I missing something?