Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angular js$作用域在Jquery函数中不起作用_Javascript_Jquery_Angularjs - Fatal编程技术网

Javascript Angular js$作用域在Jquery函数中不起作用

Javascript Angular js$作用域在Jquery函数中不起作用,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我正在使用Sweet alert来显示提醒消息。我有确认警报框,确认后我已禁用我的内容,但这不是禁用$scope在swal()中不起作用,如果单击两次,它就起作用了。我如何使它起作用。 我的HTML代码: <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="http://limonte.github.io/sweetalert2/dist/sweetalert2.css">

我正在使用Sweet alert来显示提醒消息。我有确认警报框,确认后我已禁用我的内容,但这不是禁用
$scope
swal()
中不起作用,如果单击两次,它就起作用了。我如何使它起作用。 我的HTML代码:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="http://limonte.github.io/sweetalert2/dist/sweetalert2.css">
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
    <script type="text/javascript" src="http://limonte.github.io/sweetalert2/dist/sweetalert2.min.js"></script>
    <script type="text/javascript" src="js/myscript.js"></script>
</head>
<body ng-app="app" ng-controller="myController">

    Supplier ID:<input type="text" ng-model="supplierID" ng-disabled="disable"/><br>
    Series ID:<input type="text" ng-model="seriesID" ng-disabled="disable"/><br>
    SKU ID:<input type="text" ng-model="skuID" ng-disabled="disable"/><br><br>
    <div class="action-keys">
        <button class="btn btn-default" ng-click="enable()" ng-disabled="!disable">Enable</button>
        <button class="btn btn-default" ng-click="disableCall()" ng-disabled="disable">Disable</button>
    </div>
</body>

这是我的示例代码启用工作正常,禁用功能内确认不工作。请帮忙。提前感谢。

当发生超出范围的事情时,只需使用
$scope.$apply
。注意电话

$scope.$apply(function(){
    //everything here will trigger digest cycle
    //everything...
});
angular.module('app',[])
.controller('myController',函数($scope){
$scope.disable=false;
$scope.disableCall=函数(){
游泳(
{
标题:“警告”,文本:“是否要禁用?”,键入:“警告”,showCancelButton:true,confirmButtonColor:“#3085d6”,cancelButtonColor:“#d33”,
confirmButtonText:'是',cancelButtonText:'否',confirmButtonClass:'确认类',cancelButtonClass:'取消类',allowOutsideClick:false
},功能(isConfirm){
如果(我确认){
$scope.$apply(函数(){
$scope.skuID='';
$scope.seriesID='';
$scope.supplierID='';
$scope.disable=true;
});
}否则{
返回;
} 
});
}
$scope.enable=函数(){
$scope.skuID='';
$scope.seriesID='';
$scope.supplierID='';
$scope.disable=false;
}
});

供应商ID:
序列号:
SKU ID:

使可能 使残废
当发生角度以外的事情时,只需使用
$scope.$apply
。注意电话

$scope.$apply(function(){
    //everything here will trigger digest cycle
    //everything...
});
angular.module('app',[])
.controller('myController',函数($scope){
$scope.disable=false;
$scope.disableCall=函数(){
游泳(
{
标题:“警告”,文本:“是否要禁用?”,键入:“警告”,showCancelButton:true,confirmButtonColor:“#3085d6”,cancelButtonColor:“#d33”,
confirmButtonText:'是',cancelButtonText:'否',confirmButtonClass:'确认类',cancelButtonClass:'取消类',allowOutsideClick:false
},功能(isConfirm){
如果(我确认){
$scope.$apply(函数(){
$scope.skuID='';
$scope.seriesID='';
$scope.supplierID='';
$scope.disable=true;
});
}否则{
返回;
} 
});
}
$scope.enable=函数(){
$scope.skuID='';
$scope.seriesID='';
$scope.supplierID='';
$scope.disable=false;
}
});

供应商ID:
序列号:
SKU ID:

使可能 使残废
当在angular上下文之外更新范围时,您需要通知angular运行摘要,以便查看中反映的更改view@charlietfl-我怎样才能通知你。我是安格拉斯的新手。请帮忙。@charlietfl是对的。尝试使用$scope.$apply()@Jannik-我需要插入该语句的地方。请参见@medet-Tleukabilly answer当在angular上下文之外更新范围时,您需要通知angular运行摘要,以便查看中反映的更改view@charlietfl-我怎样才能通知你。我是安格拉斯的新手。请帮忙。@charlietfl是对的。尝试使用$scope.$apply()@JANNK——在这里我需要插入那个声明。参见@ MeDET TyalAuthRealPrime:您也可以考虑将它封装在<代码> $TimeOuts< /Cult>没有参数的回调中,它将等到当前摘要完成并开除另一个。它避免了在一个摘要仍在运行时调用<代码> $Aptudio< /Cord>。如果这改进了解决方案,请发布您的答案。您也可以考虑将其封装在<代码> $TimeOuts<代码>回调中,没有持续时间参数,它将等待当前摘要完成并开除另一个。它避免在摘要仍在运行时调用
$apply
。@paultrone-如果这样可以改进解决方案,请发布您的答案。