How to unit test variables on the parent scope when using controllerAs syntax in Angular?

124 Views Asked by At

I'm trying to unit test a controller in which I'm using Angular's controllerAs syntax. I also use this to access variables in the parent scope. For example, if the parent controller is called parent, and the child controller called child, then in the view of the child I do e.g. ng-if="parent.model.age > 12".

Now, I want to unit test this. I created the controller in the unit test like this:

childController = $controller('ChildController', {
    $scope: scope
});

But as far as I can see, that doesn't allow me to access variables on ParentController? Is there a way to do that in Angular?

0

There are 0 best solutions below