动态追加时,ng-click在div中不起作用

时间:2013-12-06 20:38:44

标签: javascript jquery angularjs

我已经尝试过使用$ compile,但是我的div中的ng-click无效:

var newlist = angular.element($compile("<li ng-click='SelectSkillSet(" + $scope.SelectedSkills[x].skill
            + "," + $scope.SelectedSkills[x].key + ",$index)' ng-style=selected(" + $scope.SelectedSkills[x].key
            + ",$index) id='skill" + $scope.SelectedSkills[x].key + "'>" + $scope.SelectedSkills[x].skill
            + "<div class='prfcncy' id='prof5' ng-style='selectProficiency(5)' ng-click='SetProficiency(5)' style='border:1px #2585C9 solid;width:10px;height:10px;float:right;margin-right:5px;margin-top:5px;'>&nbsp;</div>"
            + "<div class='prfcncy' id='prof4' ng-style='selectProficiency(4)' ng-click='SetProficiency(4)' style='border:1px #2585C9 solid;width:10px;height:10px;float:right;margin-right:3px;margin-top:5px;'>&nbsp;</div>"
            + "<div class='prfcncy' id='prof3' ng-style='selectProficiency(3)' ng-click='SetProficiency(3)' style='border:1px #2585C9 solid;width:10px;height:10px;float:right;margin-right:3px;margin-top:5px;'>&nbsp;</div>"
            + "<div class='prfcncy' id='prof2' ng-style='selectProficiency(2)' ng-click='SetProficiency(2)' style='border:1px #2585C9 solid;width:10px;height:10px;float:right;margin-right:3px;margin-top:5px;'>&nbsp;</div>"
            + "<div class='prfcncy' id='prof1' ng-style='selectProficiency(1)' ng-click='SetProficiency(1)' style='border:1px #2585C9 solid;width:10px;height:10px;float:right;margin-right:3px;margin-top:5px;'>&nbsp;</div>"
            + "</li>")($scope));
        $("#RightList").append(newlist);

li中的ng-click正在工作,但不在div中。

0 个答案:

没有答案