maxisam
maxisam

Reputation: 22745

how to do unit-test on compiled template when using "controller as"?

I try to unit-test my controller with template. I can test it if everything ties to $scope. However, once I use "controller as" syntax, it doesn't work. That make sense because now everything ties to controller. But how to make it work then ?

I use Jasmine with Karma as my test environment.

Upvotes: 2

Views: 123

Answers (2)

maxisam
maxisam

Reputation: 22745

I figured something out.

Ctrl = $controller('Ctrl as vm', { $scope: $scope });

Upvotes: 0

harishr
harishr

Reputation: 18065

lets say you have vm as the controllerAs name. then you can use $scope.vm to get access to the model

Upvotes: 2

Related Questions