在使用输入创建表单模式后,它的工作正常。但是现在要删除的简单模式什么也没显示。
HTML
<script type="text/ng-template" id="delete.html">
<div class="modal-header">
<h3 class="modal-title">Löschen {{this.selectedKey}}{{$ctrl.this.selectedKey}}{{ctrl.this.selectedKey}}
{{$ctrl.this.selectedKey._id}} {{ this.selectedKey._id }} | {{ctrl.this.selectedKey._id}}?</h3>
</div>
<div class="modal-body">
Sind sie sich sicher das sie diesen Key: {{$ctrl.selectedKey.Name }} löschen wollen ?
</div>
<div class="modal-footer">
<button class="btn btn-danger" ng-click="delete()">Löschen</button>
<button class="btn" ng-click="close()">Abbrechen</button>
</div>
</script>
控制器
// Modals
deleteKey(selectedKey) {
this.$uibModal.open({
scope: this.$scope,
templateUrl: 'delete.html',
controller: ['$scope', '$uibModalInstance', '$http', 'selectedKey', function($scope, $uibModalInstance, $http, selectedKey) {
this.selectedKey = selectedKey;
this.$http = $http;
$scope.close = function() {
$uibModalInstance.dismiss();
};
$scope.delete = () => {
this.$http.delete('/api/dict_keys/' + selectedKey._id);
window.location.reload();
$uibModalInstance.close();
}
}],
resolve: {
selectedKey: () => {
return selectedKey;
}
}
});
}
它正在获取 selectedKey 并将其删除。但是在我的模态中,没有这个键的输出来显示现在选择的。正如你所看到的,我在 .html 中尝试了几件事作为 {{with controller/without}}。在 .js 中发送 selectedKey 作为解析。将其注入控制器等。
我在哪里错过了什么或做错了什么?
解决方案:
控制器
deleteKey(selectedKey) {
this.$uibModal.open({
scope: this.$scope,
templateUrl: 'delete.html',
controller: ['$scope', '$uibModalInstance', '$http', 'selectedKey', function($scope, $uibModalInstance, $http) {
$scope.selectedKey = selectedKey;
this.$http = $http;
$scope.close = function() {
$uibModalInstance.dismiss();
};
$scope.delete = () => {
this.$http.delete('/api/dict_keys/' + selectedKey._id);
window.location.reload();
$uibModalInstance.close();
};
}],
resolve: {
selectedKey: () => selectedKey
}
});
}
HTML
<script type="text/ng-template" id="delete.html">
<div class="modal-header">
<h3 class="modal-title">Löschen {{selectedKey.Name}}?</h3>
</div>
<div class="modal-body">
Sind sie sich sicher das sie diesen Key: {{selectedKey.Name}} löschen wollen ?
</div>
<div class="modal-footer">
<button class="btn btn-danger" ng-click="delete()">Löschen</button>
<button class="btn" ng-click="close()">Abbrechen</button>
</div>
</script>