angularjs - npm gives an error TypeError: Cannot read property '$valid' of undefined at Object.$scope.save -


my angular controller is:

myapp.controller('newconsultant', ['$scope', '$http', '$location', function($scope, $http, $location) {      $scope.save = function(data) {         console.log("assignment data is:" + data);          $scope.input = data;          if ($scope.assignment.$valid)         {              $http.post('./ccs/enrollment/save', $scope.input).success(function(data) {                 $location.path('/ldp/lem/el');             });         }      };   }]); 

my controller spec is:

    describe('controller: newconsultant', function() {      beforeeach(inject(function($controller){         scope={};         $controller('newconsultant',{$scope:scope});     }));      it('check save function defined or not',function(){         expect('save').tobedefined();     });      it('check save function defined or not', function() {         scope.save(2);         expect(scope.input).toequal(2);      });  }); 

when test code karma sent error: typeerror: cannot read property '$valid' of undefined @ object.$scope.save first test run got error @ second one. please 1 me. in advance.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -