[英]No Output in uibModal in {{…}}
用输入创建表单模态后,其工作正常。 但是现在,要删除的简单模态什么也没显示。
的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并将其删除。 但是在我的模态中,没有此键的输出以显示现在已选择的键。 就像您看到的那样,我在{.with controller / without}}中尝试了几种.html格式。 在.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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.