1

I am trying to put together some tests of a component. I have the following

describe(`selecting an item`, () => {
    let element, $scope;

    beforeEach(module('my-app'))
    beforeEach(inject(($compile, $rootScope) => {
        $scope = $rootScope;
        element = $compile(`
            <item-selector parent-id="pid">
            </item-selector>
        `)($scope)

        //call $ctrl.activate() on the component's controller
    }))

})

the controller for item-selector has an activate() method. How can I invoke it from my test? $scope doesn't seem to contain any reference.

George Mauer
  • 117,483
  • 131
  • 382
  • 612

1 Answers1

6
let ctrl = element.controller('item-selector')
Justin Obney
  • 1,078
  • 3
  • 13
  • 25