javascript - Angular Validation not working when dot in model -
angular validation working when there no dot(.) in model in following code...
<div class="form-group"> <label for="title">post title</label> <input ng-model="new_title" class="form-control" name="new_title" type="text" required/> <p class="error" ng-show="addform.new_title.$touched && addform.new_title.$invalid">this field required</p> </div>
but not working when use ng-model="new.title"
in following code...
<div class="form-group"> <label for="title">post title</label> <input ng-model="new.title" class="form-control" name="new.title" type="text" required/> <p class="error" ng-show="addform.new_title.$touched && addform.new.title.$invalid">this field required</p> </div>
here using new
in controller
$scope.submit = function(){ var request = crud.create($scope.new); request.success(function(response){ $scope.flash = response.status; }); };
help appreciated
you should not change name along model.
<div class="form-group"> <label for="title">post title</label> <input ng-model="new.title" class="form-control" name="new_title" type="text" required/> <p class="error" ng-show="addform.new_title.$touched && addform.new_title.$invalid">this field required</p> </div>
this how should like.
the validation doesn't check model. checks form model bind scope when using name
attribute. when checking errors, use name
attributes of form , inputs. need change name of input new.title
new_title
.
Comments
Post a Comment