Uncaught TypeError: $scope.mvp.$setUntouched is not a function angularjs 1.4


I am getting following error while trying to remove ngTouch classes from my form. This error clearly reflects that I am using angularjs1.4 which already has this function. However I am still getting this error

VM3202:1 Uncaught TypeError: $scope.mvp.$setUntouched is not a function
    at n.eval (eval at evaluate (unknown source), <anonymous>:1:12)
    at Object.InjectedScript._evaluateOn (<anonymous>:895:55)
    at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34)
    at Object.InjectedScript.evaluateOnCallFrame (<anonymous>:954:21)
    at n.$scope.resetPerson (http://localhost:55607/app/controller/personController.js:20:19)
    at fn (eval at <anonymous> (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:212:83), <anonymous>:2:224)
    at http://localhost:55607/Scripts/angular-touch.min.js:12:197
    at n.$get.n.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:134:493)
    at n.$get.n.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:135:217)
    at HTMLButtonElement.<anonymous> (http://localhost:55607/Scripts/angular-touch.min.js:12:179)

Here is my CSS

input.ng-invalid.ng-touched.ng-pristine {
    border-color: #FA787E;
    box-shadow: 0 0 10px #FA787E;

input.ng-valid.ng-touched {
    border-color: #78FA89;
    box-shadow: 0 0 10px #78FA89;

Controller reset method

$scope.resetPerson = function () {
            angular.copy({}, mvp);

Form definition

<form novalidate name="mvp" class="form-horizontal" role="form">

Is it a css issue, the way I defined?


I was able to make it working. Issue was in my reset method in controller.

$scope.resetPerson = function () {
            angular.copy({}, $scope.person); //this fixed the issue

My model was $scope.person and I was setting angular.copy({}, mvp); instead which means I was setting form mvp = {}. However I didn't understand why did I get error $setUntouched is not a function

Problem courtesy of: Shantanu Gupta


Problem is that your form is not being sent to your angular function by it's name.

 $scope.master = {};
 $scope.reset = function(mvp) {
    if (mvp) {
       $scope.person = angular.copy($scope.master);

I tried to answer your question with a question. It did not work out (: This one should ... let me know

It was undefined because you set your form to an object with the copy and setUntouched is a form controller and not an obj controller

Solution courtesy of: ODelibalta


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.