我有一个jQuery UI对话框,在这个弹出窗口中,我有一个带有angular和Ajax请求的动态<select>
。如果单击按钮,则会显示我的对话框,但即使对话框不可见,也会播放AngularJS脚本。
我使用条件if($("#MyDialog).dialog("isOpen") ===true)"
它有效,但我不知道在显示对话框时如何“重新加载”我的Angular Controller以加载选择输入...
我试过了:MyController(angular.element($('div[ng-controller="MyController"]')).scope(), angular.element($('div[ng-controller="MyController"]')).http);
但它不起作用......有什么想法吗?
我的控制器代码:
function MyController($scope, $http) {
if ($("#myDialog").dialog("isOpen") === true) {
$http.
success(function (data, status, headers, config) {
$scope.select = data;
}).
error(function (data, status, headers, config) {
alert("error !");
});
}
}
答案 0 :(得分:0)
不要访问模态是否打开,而是尝试在打开的模态按钮或链接上单击ng。
<button ng-click="loadSelectData()">Open Modal</button>
<script>
app.controller("MyController", ["$scope", "$http", function($scope, $http) {
$scope.loadSelectData = function () {
// fetch your select data
// also you can check if you already have the data before going to server
}
}]);
</script>