我在这里有一个输入按钮,我想使用模板设置它的消息。首先,当我点击按钮时,它应该运行一个函数,将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.
更多推荐
发布评论