admin管理员组文章数量:1427294
I have a kendo-ui panelbar and i am dynamically adding items to it, I dont get the ng-click event for those items.
here is I am fetching items and appending to panelbar.
$http.get("/people").success(function (data) {
var arr = [];
if (data.success) {
$.each(data.result, function (k, v) {
var item = {
text: v.name,
items: [{
text: 'email: ' + v.email
}, {
text: '<div><button class="k-button" ng-click="edit()">Edit</button></div>',
encoded: false
}]
};
arr.push(item);
});
usersPanelBar.append(arr, usersPanelBar.element.children("li:last"));
}
});
This is my controller
function userController($scope, $http, $location, $cookieStore) {
$scope.edit = function () {
alert("Will this work?");
//not workng
};
}
I have a kendo-ui panelbar and i am dynamically adding items to it, I dont get the ng-click event for those items.
here is I am fetching items and appending to panelbar.
$http.get("/people").success(function (data) {
var arr = [];
if (data.success) {
$.each(data.result, function (k, v) {
var item = {
text: v.name,
items: [{
text: 'email: ' + v.email
}, {
text: '<div><button class="k-button" ng-click="edit()">Edit</button></div>',
encoded: false
}]
};
arr.push(item);
});
usersPanelBar.append(arr, usersPanelBar.element.children("li:last"));
}
});
This is my controller
function userController($scope, $http, $location, $cookieStore) {
$scope.edit = function () {
alert("Will this work?");
//not workng
};
}
Share
Improve this question
edited Oct 20, 2013 at 9:47
Iman Mahmoudinasab
7,0144 gold badges49 silver badges70 bronze badges
asked Oct 18, 2013 at 9:32
nishnish
2561 gold badge6 silver badges15 bronze badges
0
3 Answers
Reset to default 3You need to use $pile
service to tie your little added snippet to the scope.
You may find an example here - angular, in directive, adding to the template an element with ng model
How about to add something like this to your usersPanelBar
<div ng-repeat="item in items">
Email: {{item.email}}
<div><button ng-click="edit()">Edit</button></div>
</div>
And push all retrieved data in the items array
function(data) {
if(data.success) {
$scope.items = data.result;
}
});
Does it make sense?
app.controller('TestController', function ($pile, $scope) {
$scope.AppendDetailSuites = function () {
var html = 'button type="button" id="btn" ng-click="LoadContiguousSuite(' + SuiteId + ');" class="btn btn-white btn-sm" >Edit</button> ';
var updatedhtml = $pile(html)($scope);
$("#tbDetailContiguous").append(updatedhtml);
}
}
本文标签: javascriptAngularJS ngclick not working for dynamically appended kendo panelbarStack Overflow
版权声明:本文标题:javascript - AngularJS ng-click not working for dynamically appended kendo panelbar - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745494247a2660739.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论