angularjs - mdDialog 不会显示 templateUrl
问题描述
我们的团队正在使用 mdDialog 来调出一个允许用户编辑问卷答案的模式。
$scope.editQuestionFnct = function(val){
$scope.editWidget = {};
//alert(val);
spUtil.get("gateway_questionnaire_widget", {//call new instance of this widget
//sys_id: $scope.params.refID,
task_id: $scope.data.task_id,
quest_id: val,
request: 'edit',
taskTable: $scope.data.task_table,
questionnaire_table: $scope.params.questionnaireTable,
serviceID: $scope.params.serviceID,
refID: $scope.params.refID,
taskCompleted: false,
editRequest: true
}).then(function(response) {
$scope.editWidget = response;//var to hold widget response to display in modal
$scope.showPrerenderedDialog('#editQuestion');
});
}
$scope.showPrerenderedDialog = function(name) {
$mdDialog.show({
templateUrl: name,
parent: angular.element(document.body),
clickOutsideToClose:true
});
};
$scope.closeDialog = function($scope){ //closes angular dialog window
$mdDialog.hide($scope);
}
$scope.closeSummDialog = function($scope){ //closes angular dialog window
$mdDialog.hide($scope);
}
<script type="text/ng-template" id="editQuestion">
<div class="md-dialog-container" >
<md-dialog style="background-color: #ffffff;" aria-label="edit dialog">
<md-toolbar style="background-color: #022C68; width: 100%;">
<h1 class="md-toolbar-tools" style="color: #ffffff;">Edit Response</h1>
</md-toolbar>
<md-dialog-content style="background-color: #ffffff;">
<div id="editQuestDiv" style="min-width: 700px;">
<sp-widget widget="editWidget"></sp-widget>
</div>
</md-dialog-content>
<md-dialog-actions layout="row">
<span flex></span>
<md-button ng-click="closeDialog()" style="background-color: #022C68; color: #ffffff;">
Close
</md-button>
</md-dialog-actions>
</md-dialog>
</div>
</script>
上面的代码我们遇到了两个问题:
首先,我们没有使用 templateUrl,而是使用了 contentElement,这很有效。使用 contentElement 拉出一个带有需要编辑的问题的模式。但是,当用户从第一次点击中退出,然后点击另一个问题时,会出现第一次点击中出现的相同问题。之后的每次点击只会从第一次点击中提取问题。
在做了一些阅读之后,我们决定尝试使用 templateUrl 来代替,但是使用上面的那个会打开一个没有任何内容的模式:
有人可以解释我们做错了什么吗?我们是否对 contentElement 做错了,只有第一次点击的问题仍然存在?如果我们要使用 templateUrl,为什么我们的 modal 没有出现?
谢谢!
解决方案
推荐阅读
- tensorflow - ModuleNotFoundError:没有名为“tflite_support.metadata_writers”的模块
- amazon-s3 - Django 中的 Sorl 缩略图。是否可以根据模型设置两个或多个存储配置文件?
- java - Spring引导上下文不断尝试连接到java rmi服务器并失败
- docker - 如何码头化.net项目
- powershell - 将 Resolve-DNSname 添加到 Hashtable
- windows - 限制 Windows 上的 git bash 执行
- merge - SSIS合并联接不匹配内部联接上的所有行
- javascript - 使用 unix() 创建 Unix 纪元时间
- c# - 当属性公开子属性的属性时如何解决反序列化问题
- nexus3 - 如何在没有网络上传的情况下将转储导入到 nexus OSS?