使用范围时,$ dialog中的ngModel字段未更新ngDialog $ scope变量:$ scope [英] ngDialog $scope variables not being updated by ngModel fields in $dialog when using scope: $scope

查看:131
本文介绍了使用范围时,$ dialog中的ngModel字段未更新ngDialog $ scope变量:$ scope的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制器,可以使用ngDialog.open创建一个对话框。我在弹出框$对话框中指定范围:$ scope并使用ng-model设置范围变量。但是,值未在控制器$ scope中设置。 ng-click函数可以调用$ scope中的函数。



我有什么遗漏,我在这里搜索了很多内容和github,阅读了文档并使用了项目中github上提供的所有示例。 / p>

下面的JS Fiddles解释道。它显示范围:$ scope不是.open()的范围。它是单向绑定,不会回到$ scope。 .openConfrm()似乎有预期的行为。



ngDialog.open() - http ://jsfiddle.net/s1ca0h9x/ (固定!!按预期工作)



ngDialog.openConfirm() - http://jsfiddle.net/tbosLoa9/ (按预期工作)

  var myApplication = angular.module('myApplication',['ngDialog']); 

myApplication.controller('MainController',function($ scope,ngDialog){
$ scope.FormData = {newAccountNum:''};
$ scope.ShowNgDialog = function (){
ngDialog.open({
template:'< div>< input type =textng-model =FormData.newAccountNum/>< / div>',
plain:true,
范围:$ scope

});
}

});

解决方案

我已经编辑了原帖并在下面添加了它。 FIXED链接显示它正常工作,第二个链接显示它已损坏。添加一个点(使用javascript对象)可以解决问题。



ngDialog.open() - http://jsfiddle.net/s1ca0h9x/ (固定!!按预期工作)



ngDialog.openConfirm() - < a href =http://jsfiddle.net/tbosLoa9/ =noreferrer> http://jsfiddle.net/tbosLoa9/ (按预期工作)

  var myApplication = angular.module('myApplication',['ngDialog']); 

myApplication.controller('MainController',function($ scope,ngDialog){
$ scope.FormData = {newAccountNum:''};
$ scope.ShowNgDialog = function (){
ngDialog.open({
template:'< div>< input type =textng-model =FormData.newAccountNum/>< / div>',
plain:true,
范围:$ scope

});
}
});


I have a controller that creates a dialog with ngDialog.open. I assign scope:$scope and set scope variables with ng-model in the popup $dialog. However the values are not set in the controller $scope. The ng-click function is able to call a function in the $scope.

Is there something I am missing, I have searched quite a bit on here and github, read the docs and worked with all the examples provided on github in the project.

JS Fiddles below explains. It shows that the scope:$scope is not what it seems for .open(). It is a one way binding and does not go back to $scope. .openConfrm() seems to have the expected behavior.

ngDialog.open() - http://jsfiddle.net/s1ca0h9x/ (FIXED!! works like expected)

ngDialog.openConfirm() - http://jsfiddle.net/tbosLoa9/ (works as expected)

var myApplication = angular.module('myApplication', ['ngDialog']);

myApplication.controller('MainController', function ($scope, ngDialog) {
$scope.FormData={newAccountNum:''};
$scope.ShowNgDialog = function () {
    ngDialog.open({            
        template: '<div><input type="text" ng-model="FormData.newAccountNum"/></div>',
        plain: true,
        scope:$scope

    });
}    

});

解决方案

I have edited the original post and added it below. The FIXED link shows it working and the second shows it broken. Adding a dot (using a javascript object) fixes the problem.

ngDialog.open() - http://jsfiddle.net/s1ca0h9x/ (FIXED!! works like expected)

ngDialog.openConfirm() - http://jsfiddle.net/tbosLoa9/ (works as expected)

var myApplication = angular.module('myApplication', ['ngDialog']);

myApplication.controller('MainController', function ($scope, ngDialog) {
    $scope.FormData={newAccountNum:''};
    $scope.ShowNgDialog = function () {
        ngDialog.open({            
            template: '<div><input type="text" ng-model="FormData.newAccountNum"/></div>',
            plain: true,
            scope:$scope

        });
    }    
});     

这篇关于使用范围时,$ dialog中的ngModel字段未更新ngDialog $ scope变量:$ scope的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆