Cannot read property “loadListing” of Undefined -K

2019-09-01 15:20发布

问题:

This is my test case for checking whether the function is defined or not in the controller

Function:

  $scope.loadData = ()=> {

    LoadService.loadListing().then(function (responseData) {
             alert("Success");
            }

Test Case:

it('should have loadMeetings function', function () {
        expect(angular.isFunction(scope.loadData )).toBe(true);
    });

The Error : TypeError: Cannot read property 'loadListing' of undefined at Scope.MyCtrl.$scope.loadData