Angular/Bootstrap Modal不会调用两次TypeError: v2.deleteModalProjec
Angular/Bootstrap Modal WONT call Twice TypeError: v2.deleteModalProject is not a function
目标是能够根据用户需要调用模态,因为模态允许用户删除内容。当第二次单击而没有重新加载页面时,会出现问题。
我使用的是angular 1.5.6
我已经用谷歌搜索了两个半小时了。
我试着用jQuery附加一个随机id的唯一div,没有运气,使用这个stackoverflow问题的例子:
Twitter Bootstrap Modal多事件触发
这是我的模态HTML;
<div class='modal fade' id='deleteModalProfile' role='dialog'>
<div class='modal-dialog'>
<!-- Modal content-->
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'>×</button>
<h4 class='modal-title'>{{modal.title}}</h4>
</div>
<div class='modal-body'>
<p>{{modal.body}}.</p>
</div>
<div class='modal-footer'>
<button ng-show='modal.project' class='btn btn-default' ng-click='removeProject()'>Yes</button>
<button ng-show='modal.goal' class='btn btn-default' ng-click='removeGoal()'>Yes</button>
<button type='button' class='btn btn-default' data-dismiss='modal'>No</button>
</div>
</div>
</div>
</div>
我的函数不会调用两次;
$scope.deleteModalGoal = function(goal, index) {
$scope.modal = {"goal": true, "project": false, "title": "Delete Goal?", "body": "Do you want to delete " + goal.task + " in " + goal.title + "?"}
$scope.deleteModalGoalIndex = index;
$scope.deleteModalGoal = goal;
$("#deleteModalProfile").modal("toggle");
}
这是我的索引html;
<div ng-include="'views/modal.html'"></div>
<button type="button" ng-click="deleteModalGoal(goal, $index)" class="btn btn-danger projectTaskDelete"> <i class="fa fa-trash"></i> Task </button>
请帮助,我只是张贴,因为我没有选择。
谢谢你的时间,丹尼尔
"TypeError: v2。当myFunction与变量同名时,在第二次单击时出现"myFunction is not a function"。Angular的$scope被另一个不是函数的变量覆盖了。
我添加了一个"s"到我的函数名,这解决了问题。
$scope.deleteModalGoal是在函数$scope.deleteModalGoal中分配的,所以改变$scope.deleteModalGoal = function()…to $scope.deleteModalGoals = function()…修复。
https://github.com/angular/angular.js/issues/12353 固定: $scope.deleteModalGoals = function(goal, index) {
$scope.modal = {"goal": true, "project": false, "title": "Delete Goal?", "body": "Do you want to delete " + goal.task + " in " + goal.title + "?"}
$scope.deleteModalGoalIndex = index;
$scope.deleteModalGoal = goal;
$("#deleteModalProfile").modal("toggle");
}
原始: $scope.deleteModalGoal = function(goal, index) {
$scope.modal = {"goal": true, "project": false, "title": "Delete Goal?", "body": "Do you want to delete " + goal.task + " in " + goal.title + "?"}
$scope.deleteModalGoalIndex = index;
$scope.deleteModalGoal = goal;
$("#deleteModalProfile").modal("toggle");
}
希望这对那里的人有所帮助!
相关文章:
- Meteor Router数据函数被调用两次
- 从MySQL数据库中获取输入数据需要两次页面刷新
- Module.start()已激发两次
- Jquery点击事件必须点击两次
- Append元素在运行两次函数后不显示
- 防止双击执行两次jQuery post请求
- 我必须点击两次才能激活任何按钮操作(离子/角度)
- 单击jQuery会激发两次
- 如何避免在树上走两次
- button.单击两次删除附加操作后不工作
- 由于$compile,Javascript(Angular)嵌套指令加载了两次
- 单击元素两次后执行操作
- AngularJs正在阻止链接被点击两次
- 为什么我的路线处理程序会触发两次
- 为什么Highchart在我的rails应用程序中加载了两次?(未捕获的Highcharts错误#16)
- 在列表中至少使用两次随机生成的nr
- 检查某个键是否按下两次
- 一次点击,两次'单击'事件已启动
- 我的所有代码在使用Webpack编译时都会运行两次
- Angular/Bootstrap Modal不会调用两次TypeError: v2.deleteModalProjec