Angularjs 通行证;这";重复内容

Angularjs 通行证;这";重复内容,angularjs,function,this,ng-repeat,Angularjs,Function,This,Ng Repeat,我在表中使用ng repeat动态生成表行。当用户单击表中的复选框时,我需要使用“this”关键字调用函数。当我把它作为一个参数传递时,它在js端是未定义的。请帮助我下面是我的代码 <table class="codelisttab"> <tr><th></th><th>Employee Name</th><th>Employee Id</th></tr> <tr data-ng-r

我在表中使用ng repeat动态生成表行。当用户单击表中的复选框时,我需要使用“this”关键字调用函数。当我把它作为一个参数传递时,它在js端是未定义的。请帮助我下面是我的代码

<table class="codelisttab">
<tr><th></th><th>Employee Name</th><th>Employee Id</th></tr>
<tr data-ng-repeat="emp in employees">
<td style="width:20px;"><a data-ng-click="updateEmployeeList(emp.empid, this)" class="ui-multiselect-box commonMultiSelectClass unCatMultiselectColorSelected" id="unCatMulti_109812"></a></td>
<td>{{emp.name}}</td><td>{{emp.empid}}</td>
</tr>
<tr colspan="3"><th style="text-align:center;"><input type="button" data-ng-click="addGroup()" value="Create Group"></th></tr>

员工姓名员工Id
{{emp.name}{{emp.empid}}

myjs代码:
$scope.updateEmployeeList=函数(empid,obj){
var i=$scope.employeeList.indexOf(empid);

如果(i如果您需要函数updateEmployeeList的特殊上下文,您可以始终在前面绑定特定上下文,例如:

$scope.updateEmployeeList = $scope.updateEmployeeList.bind(this);
它将在正确的上下文中执行


但是,这不是很有角度感。

您希望这是什么?如果您想要元素,您需要将$event传递给ng,单击并获取event.currentTarget:


$scope.updateEmployeeList=函数(empid,$event){
变量i=$scope.employeeList.indexOf(empid),
obj=$event.currentTarget;

如果(i)你期望这是什么?通过javascript更改对象的样式不是“角度”的做事方式。使用
ng class
来实现这一点。如果你想要
$scope.updateEmployeeList = $scope.updateEmployeeList.bind(this);
<a data-ng-click="updateEmployeeList(emp.empid, $event)" class="ui-multiselect-box commonMultiSelectClass unCatMultiselectColorSelected" id="unCatMulti_109812"></a>

$scope.updateEmployeeList = function(empid, $event){

            var i = $scope.employeeList.indexOf(empid),
            obj = $event.currentTarget;
            if(i <= -1){
                $scope.employeeList.push(empid);
                obj.style.backgroundColor="#89e3f9";
            }
            else{
                obj.style.backgroundColor="#0e5061";
                $scope.employeeList.splice(i,1);
            }
            console.log($scope.employeeList.toString());
        }