2

I already tried using $compile, but the ng-click inside my div is not working:

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);

The ng-click in li is working but not in the div.

5
  • May be related to this stackoverflow.com/questions/16296264/… Commented Dec 6, 2013 at 20:42
  • hi Philippe, I already used $compile and also injected it in my controller and it is weird because the ng-click in the li tag is working but in the div it is not. Commented Dec 6, 2013 at 20:53
  • could you provide plunkr? Commented Dec 6, 2013 at 21:23
  • 1
    I assure you that you're misusing Angular. I've written a LOT of code with Angular and have only ever selected a dom element manually once. Commented Dec 6, 2013 at 23:31
  • @artur grzesiak jsfiddle.net/r8JL7/8 here is a fiddle Commented Dec 7, 2013 at 2:06

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.