创建表单模式后输入工作正常。 但现在一个简单的删除模式没有显示任何内容。
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作为解析。在Controller中注入它等等。
我在哪里错过了什么或做错了什么?
解决方案:
控制器
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>