ReferenceError:未定义$ event

时间:2017-03-28 05:19:39

标签: angularjs

使用底片时出现错误

div(flex="15" data-ng-click="showGridBottomSheet(testExecution)" class="link-style") 

以下是被调用函数

$scope.showGridBottomSheet = function(obj) {

    testexecutionServices.testexeustionObj = obj;
    $mdBottomSheet.show({
        scope: $scope,
        targetEvent: $event,
        preserveScope: true,
        templateUrl: 'testexecutions/testExecutionResult',
        controller: 'testexecutionCtrl'
    }).then(function(clickedItem) {

    }, function() {});
};

1 个答案:

答案 0 :(得分:0)

我认为您需要在函数参数中添加$event,如下所示:

$scope.showGridBottomSheet = function(obj, $event) {

testexecutionServices.testexeustionObj = obj;
$mdBottomSheet.show({
    scope: $scope,
    targetEvent: $event,
    preserveScope: true,
    templateUrl: 'testexecutions/testExecutionResult',
    controller: 'testexecutionCtrl'
}).then(function(clickedItem) {

}, function() {});
};

并在您的HTML中,将$event传递给函数调用:

div(flex="15" data-ng-click="showGridBottomSheet(testExecution,$event)" class="link-style") 

如果您不使用它,请将其设置为null

相关问题