gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 16:17:09 24 4
gpt4 key购买 nike

我正在从 ngDialog 弹出窗口更新一个作用域变量。

查看:

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

controller.js

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

如果我在非弹出 HTML 中具有上述 View ,则 ng-model 更新和 View 更改。

ngDialog:

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

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

最佳答案

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

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',......

关于javascript - ngDialog - 弹出窗口不更新范围变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29466337/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com