NG-CLICK NOT WORKING

118 views
Skip to first unread message

Rohit Yadav

unread,
Dec 21, 2015, 2:46:58 AM12/21/15
to AngularJS
Hi Guys,
              I have came through one problem, am new to Angular Framework. In my one UI component  "ng-click"  is not triggered. The Details are as follows

             1-  I have ng-Dialogue in that i have Multiselect Box, where user selects some Customers .

             2- User Click on Dialogue SAVE BUTTON, a function is called on this saveManagers .

             3-  Inside  $scope.savemanagers() function , i am dynamically forming a  UI component .

             4-  Applied $compile(ui-component)($scope);

            5- This UI- component has ng-click on DIV, 

            6- ng-click not working in this case

    NOTE:   Dynamic UI component which i made during Controller Load time , there ng-click is working, but when dynamic component made inside a  function  ng-click not working

CODE is as follows

      $scope.saveManagers = function(){

        console.log($scope);
        //$scope.alert();
        console.log("========== SCOPE ===========");
        CmanagerList = "";
        $scope.mangerListArr = [];
        console.log($("#multiselect_to").val());
        ngDialog.close();
   

  angular.forEach($("#multiselect_to option:selected"), function(val){
      console.log(val.value+"::::"+val.length);
   if (val != undefined) {

                if(userService.getuserExternalId().indexOf(val.value.split(":")[1]) == -1)
                {

                    userService.setuserExternalId(val.value.split(":")[1]);

                     $scope.mangerListArr.push(val.value.split(":")[1]);

                     console.log("====Selected Text======");
                     //CmanagerList = CmanagerList+"<div data-manager-id='"+$this.val().split(":")[1]+"' class='selectedManager'>"+$this.text()+'<span ng-click=\'removeSelection(1234)\' class="selection-close">x</span></div>';

                     CmanagerList = "<div class='selectedManager'><span>BRUNO</span><div ng-click='alert1()' class='selection-close'>x</div></div>";
                    
                     angular.element(".managerList").append($compile(CmanagerList)($scope));
                  }
                }

   });

          //$scope.$apply();
        
         console.log("====== EXTERNAL IDDSSS =========");
         console.log(userService.getuserExternalId());

         console.log($scope.mangerListArr);
         //$(".managerList").append($compile(CmanagerList)($scope));
        //console.log(temp1);
}

$scope.removeSelection = function(){
   alert(" ");

}

            

Ankush Joshi

unread,
Dec 31, 2015, 5:01:06 AM12/31/15
to AngularJS
Hello, 

You need to create object for dynamic control you are creating .. then you can get event for tht
Reply all
Reply to author
Forward
0 new messages