Javascript angular ui引导模式无法与ng repeat一起正常工作
嘿,伙计们,我试着将每个模式分配给我拥有的每个项目,但它似乎不像我期望的那样工作 我希望它一次只能触发一个模态,而不是全部触发 例如,我这里有3个项目,每个项目都有其删除按钮,每个按钮都可以触发modalbox 但是,我单击任何Javascript angular ui引导模式无法与ng repeat一起正常工作,javascript,angularjs,angular-ui-bootstrap,Javascript,Angularjs,Angular Ui Bootstrap,嘿,伙计们,我试着将每个模式分配给我拥有的每个项目,但它似乎不像我期望的那样工作 我希望它一次只能触发一个模态,而不是全部触发 例如,我这里有3个项目,每个项目都有其删除按钮,每个按钮都可以触发modalbox 但是,我单击任何删除按钮,它将触发所有modalbox,如下所示 这是我目前掌握的代码 html(模式视图) modalInstanceCrtl var ModalInstanceCtrl = function ($scope, $modalInstance,items) {
删除按钮
,它将触发所有modalbox,如下所示
这是我目前掌握的代码
html(模式视图)
modalInstanceCrtl
var ModalInstanceCtrl = function ($scope, $modalInstance,items) {
$scope.modalData = items;
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
$scope.confirm = function(titleform){
if(titleform === items.title){
$http.delete('/contentHandler/post/'+$routeParams.permalink+'/delete').
success(function(data){
$location.path('/');
}).error(function(err){
alert(err);
$scope.errorMessage = err;
});
$modalInstance.dismiss('cancel');
}else{
$scope.errorMessage = "Please enter the correct title "
}
}
};
var ModalInstanceCtrl = function ($scope, $modalInstance, item) {
$scope.data = item;
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
$scope.confirm = function(titleform){
if (titleform === items.title) {
$http.delete('/contentHandler/post/'+$routeParams.permalink+'/delete').
success(function(data){
$location.path('/');
}).error(function(err){
alert(err);
$scope.errorMessage = err;
});
$modalInstance.dismiss('cancel');
}else{
$scope.errorMessage = "Please enter the correct title "
}
}
};
请问这是正确的做法吗 缺少一些信息,但可能应该是这样的: html(模式视图) 删除按钮需要类似于
ng click=“删除(数据)”
。其中,数据
为单通道
modalInstanceCrtl
var ModalInstanceCtrl = function ($scope, $modalInstance,items) {
$scope.modalData = items;
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
$scope.confirm = function(titleform){
if(titleform === items.title){
$http.delete('/contentHandler/post/'+$routeParams.permalink+'/delete').
success(function(data){
$location.path('/');
}).error(function(err){
alert(err);
$scope.errorMessage = err;
});
$modalInstance.dismiss('cancel');
}else{
$scope.errorMessage = "Please enter the correct title "
}
}
};
var ModalInstanceCtrl = function ($scope, $modalInstance, item) {
$scope.data = item;
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
$scope.confirm = function(titleform){
if (titleform === items.title) {
$http.delete('/contentHandler/post/'+$routeParams.permalink+'/delete').
success(function(data){
$location.path('/');
}).error(function(err){
alert(err);
$scope.errorMessage = err;
});
$modalInstance.dismiss('cancel');
}else{
$scope.errorMessage = "Please enter the correct title "
}
}
};
ng repeat='data in modalData'
将重复多次删除确认。你应该发布一个小的plunker,这样我们就可以看到当点击delete时会发生什么。你似乎给了它一份物品清单,而不仅仅是有问题的物品。我能知道我该怎么做吗?类动力模态
$http.post('/channelHandler/getChannelByUser',data).
success(function(channelData) {
$scope.channels = channelData;
$scope.delete = function ( currentChannel ) {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: ModalInstanceCtrl,
resolve: {
item: function () {
return currentChannel;
}
}
});
}
});
var ModalInstanceCtrl = function ($scope, $modalInstance, item) {
$scope.data = item;
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
$scope.confirm = function(titleform){
if (titleform === items.title) {
$http.delete('/contentHandler/post/'+$routeParams.permalink+'/delete').
success(function(data){
$location.path('/');
}).error(function(err){
alert(err);
$scope.errorMessage = err;
});
$modalInstance.dismiss('cancel');
}else{
$scope.errorMessage = "Please enter the correct title "
}
}
};