ngDialog - 弹出窗口不更新范围变量

时间:2015-04-06 06:20:09

标签: javascript angularjs ng-dialog

我正在从ngDialog弹出窗口更新一个范围变量。

查看:



<input type="radio"  name="file_selector" value={{file.id}} ng-model="selected_file.id" ></input>
 
&#13;
&#13;
&#13;

controller.js

 $scope.selected_file   = {'id' : '22'};

如果我在非弹出HTML中有上述视图,则ng-model更新并查看更改。

ngDialog:

&#13;
&#13;
$scope.openUploadPopup = function() {
		ngDialog.open({
			template: 'partials/upload.html',
			controller: 'notificationController',
			className: 'ngdialog-theme-default',
			scope: $scope
			});
} 
&#13;
&#13;
&#13;

编辑:Plunker:http://plnkr.co/edit/8TUtwixKwvVaycDuvHd9?p=preview

1 个答案:

答案 0 :(得分:2)

我改变了你的文件,对我有用。

HTML:

<html>

  <head>
    <script src="https://code.angularjs.org/1.4.0-beta.6/angular.js"></script>
    <script  src="http://likeastore.github.io/ngDialog/js/ngDialog.min.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
  </head>

  <body ng-app="notifications_web_portal" ng-controller="notificationController">
    <div ng-view>
    <h1>Hello Plunker!</h1>
      <span> File selected : {{selected_file.id}}</span>
      <a href='javascript:void(0)' ng-click="openUploadPopup()" >Open Dialog</a>
      </div>
  </body>

</html>

JS:

// Code goes here
var notifApp = angular.module('notifications_web_portal', ['ngDialog']); 

notifApp.controller('notificationController', function($scope, $rootScope, $window , ngDialog) {
  $scope.openUploadPopup = function() {

    ngDialog.open({
      template: '<input type="radio"  name="file_selector" value="87" ng-model="selected_file.id" ></input>',
      controller: 'notificationController',
      plain: true,
      className: 'ngdialog-theme-default',
      scope: $scope
      });
  }
});

完成的更改:

  • plain: true已添加
  • notifApp.controller('notificationController',......