代码之家  ›  专栏  ›  技术社区  ›  mpsbhat

甜心是用angularjs确认的

  •  0
  • mpsbhat  · 技术社区  · 9 年前

    我有一个样品 code here 我想继续或使用添加新值的位置 isConfirm 带着甜蜜的警觉。

     swal({
          title: "Are you sure?",
          text: "Save the name",
          type: "warning",
          showCancelButton: true,
          confirmButtonColor: "#DD6B55",
          confirmButtonText: "Save and Add Another",
          cancelButtonText: "New",
          closeOnConfirm: true,
          closeOnCancel: true
        }, function(isConfirm) {
          if (isConfirm) {
            // saves the input values & selected values using ajax call
            $scope.test = '';
          } else {
           // reset input values & selected values and fresh input again
            $scope.test = '';
            $scope.mysel = '-1';
          }
        });
    

    但在单击保存并添加另一个按钮后,模型值第一次没有清除。此外,它在单击时没有重置 New .代码有什么问题?

    1 回复  |  直到 9 年前
        1
  •  2
  •   developer033    9 年前

    你必须使用 $scope.$apply(); ,否则它不会反映 $scope 变量

    DEMO

    你可以检查 here $scope.apply() .

    我希望它有帮助!

    推荐文章