我为父div和子div进行了ng-click以触发child的click事件我给$ event.stopPropogation() 然后单击将在iframe中加载文件。
但是当我将$ event.stopPropogation()传递给子div时,内容未加载,当我删除它时,它正在加载
我不明白我做错了什么,而且根本没有错误
这是html
<div ng-class="{'col-xs-6': myVar=='something'}">
<div class="panel panel-default panel-height" ng-repeat="candidateInfo in aCandidateDetails track by $index" ng-click="fnInterviewView(candidateInfo.name)">
<div class="panel-heading header-background">
<div stop-watch time="xyz" name="candidateInfo.name" time-of-interview="candidateInfo.doi" class="stop-watch"></div>
<div class="row">
<div class="col-xs-2"><a style="cursor:pointer" class="pull-right">{{candidateInfo.name}}</a></div>
<div class="col-xs-offset-9"><a style="cursor:pointer" ng-click="fnVar(candidateInfo.name, candidateInfo.filepath,$index);$event.stopPropogation()" data-toggle="collapse" data-target="{{'#'+'collapse'+'_' + name}}">{{candidateInfo.name}} resume</a></div>
</div>
</div>
</div></div>
这是下面的控制器代码
angular.module('hrPortalApp')
.controller('candidateInterviewCtrl', function($scope, $state, $sce, getCandidateInterviewListService) {
getCandidateInterviewListService.fnGetCandidateDetails("xyz").then(function(response) {
$scope.aCandidateDetails = response;
console.log(response);
$scope.toggle = "accor"
});
$scope.file = $sce.trustAsResourceUrl('http://localhost:4000/api/uploads/574ed76718153dac202679b9_resume.pdf');
$scope.fnVar = function(name, filepath, index, event) {
$scope.file = $sce.trustAsResourceUrl('http://localhost:4000/' + filepath);
$scope.checkVar = !$scope.checkVar;
if ($scope.checkVar) {
$scope.myVar = "something";
} else {
$scope.myVar = false;
}
};
$scope.fnInterviewView = function(name) {
$state.go('main.Topics', {
"candidateDetails": $scope.aCandidateDetails,
"name": name
})
};
});
任何帮助将不胜感激
答案 0 :(得分:0)
将$ event传递给$ scope.fnVar函数并在完成工作后执行停止传播,如下所示,而不是在html ....
$scope.fnVar = function(name, filepath, index, event) {
$scope.file = $sce.trustAsResourceUrl('http://localhost:4000/' + filepath);
$scope.checkVar = !$scope.checkVar;
if ($scope.checkVar) {
$scope.myVar = "something";
} else {
$scope.myVar = false;
}
event.stopPropagation();
};