NgBootbox与双向绑定模板不起作用(NgBootbox with two way binding template not working)

系统教程 行业动态 更新时间:2024-06-14 16:52:52
NgBootbox与双向绑定模板不起作用(NgBootbox with two way binding template not working)

我在这里有一个输入按钮,我想使用模板设置它的消息。首先,当我点击按钮时,它应该运行一个函数,将scope.info的值设置为info,然后模态应该弹出包含模板有双向绑定。 但绑定不起作用

Code: index.html <input type="button" name="name" value="New" ng-click="verify()" ng-bootbox-title="Warning" ng-bootbox-custom-dialog ng-bootbox-custom-dialog-template="temp.html" ng-bootbox-buttons="customDialogButtons" ng-bootbox-class-name="some-class" /> temp.html <div>{{info}}</div> prog.js $scope.verify = function(){ $scope.infos= "info"; }; SOLVED! SOLUTION: prog.js $scope.verify = function(){ $rootScope.infos= "info"; };

i have here an input button where i want to set its message using a template.At first, when i clicked the button it should run a function which will set scope.info value to info, and then the modal should popup containing the template which has the two way binding. but the binding is not working

Code: index.html <input type="button" name="name" value="New" ng-click="verify()" ng-bootbox-title="Warning" ng-bootbox-custom-dialog ng-bootbox-custom-dialog-template="temp.html" ng-bootbox-buttons="customDialogButtons" ng-bootbox-class-name="some-class" /> temp.html <div>{{info}}</div> prog.js $scope.verify = function(){ $scope.infos= "info"; }; SOLVED! SOLUTION: prog.js $scope.verify = function(){ $rootScope.infos= "info"; };

最满意答案

您的代码工作正常,您只是错过拼写您的div中的变量名称( {{infos}} )。

JSFiddle工作


从评论更新

尝试将信息值放在$rootScope而不是$scope ,似乎你有一个可访问性的问题。

Your code works correctly, you just miss spelled the name of your variable ({{infos}}) in your div.

JSFiddle working.


Update from comments

Try to put infos value in $rootScope instead of $scope, it seems you have an issue of accessibility.

更多推荐

本文发布于:2023-04-05 12:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/094afb534d0597cc883603907009c553.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:绑定   双向   不起作用   模板   NgBootbox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!