Discussion:
[AngularJS] NG-CLICK NOT WORKING
Rohit Yadav
2015-12-21 07:46:58 UTC
Permalink
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(" ");

}
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Ankush Joshi
2015-12-31 10:01:06 UTC
Permalink
Hello,

You need to create object for dynamic control you are creating .. then you
can get event for tht
Post by Rohit Yadav
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(" ");
}
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Loading...