angularjs - how to mock ngModel? -


so testing controller, referencing property specified ngmodel in dom. while testing controller, don't have template. whenever $scope.foo.property being accessed in controller, throws error.

in test, can define property before instantiate controller :

it('should mock ng-model', inject(function($rootscope, $controller) {      $rootscope.foo = {         property: 'mock value'     };      $controller('mycontroller', {$scope: $rootscope}); }))); 

Comments

Popular posts from this blog

android - Inheriting from Theme.AppCompat* -

broadcastreceiver - android BOOT_COMPLETED not received if not activity intent-filter -

basic authentication with http post params android -