gpt4 book ai didi

css - 带有 ui-bootstrap-tpls-0.13 和 bootstrap 3.3.2 的 Ui-bootstrap-modal,angular 1.3.14 不工作

转载 作者:太空宇宙 更新时间:2023-11-04 03:02:39 26 4
gpt4 key购买 nike

如标题所述,模态不显示。表单的内容是通过 formly 加载的,模板的内容似乎加载了,但它只显示了非常薄的模态,有覆盖但没有内容。

我有一个主 Controller ,其中有:

$scope.add = function(){
$modal.open({
templateUrl: 'app/js/templates/popupAddCarForm.html',
controller: 'FormsController',
controllerAs: 'vm',
backdrop: 'static',
resolve: {
formData: function(){
return {
fields: getFormFields(),
model: {}
}
}
}
});
};

我的html是这样的:

<script type="text/ng-template" id="popupAddCarForm">
<div class="modal">
<div class="modal-dialog">
<div class="modal-header">
<h3 class="modal-title">Adauga masina</h3>
</div>
<div class="modal-body">
<form name="vm.addCarForm">
<formly-form model="vm.formData.model" fields="vm.formData.fields">
</formly-form>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-default" type="submit" >Adauga</button>
</div>
</div>
</div>

我的表单 Controller 是这样的:

davidintercar.controller('FormsController',
function($modalInstance, formData) {
var vm = this;
//debugger;

vm.formData = formData;
vm.originalFields = angular.copy(vm.formData.fields);

}
);

结果是这样的:

The modal is in the red square

后期编辑:

为了排除其他疑虑,下面是demo中的代码:

app.controller('ModalInstanceCtrl', function ($modalInstance, formData) {
var vm = this;
debugger;

// function assignment
vm.ok = ok;
vm.cancel = cancel;

// variable assignment
vm.formData = formData;
vm.originalFields = angular.copy(vm.formData.fields);

// function definition
function ok() {
$modalInstance.close(vm.formData.model);
}

function cancel() {
$modalInstance.dismiss('cancel');
};

});

链接:angular-formly.com/#/example/integrations/ui-bootstrap-modal

稍后,稍后编辑:

笨蛋:http://plnkr.co/edit/8wgL4t2oXsFFeLBKGGW8?p=preview

文件夹结构:

--app
----js
------controller
------services
------templates
------view
----app.js
intex.html

我的 popupAddCarForm.html 位于模板目录中,但正如您在 plunker 中看到的那样,它不会呈现我加载的内容,即使在同一目录中,尽管是一个单独的模板文件。

最佳答案

模态模板不需要模态和模态对话框层——它们将由 Bootstrap 生成。

<script type="text/ng-template" id="popupAddCarForm.html">
<div class="modal-header">test
<h3 class="modal-title">Adauga masina</h3>
</div>
<div class="modal-body">
<form name="vm.addCarForm">
<formly-form model="vm.formData.model" fields="vm.formData.fields">
</formly-form>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-default" type="submit" >Adauga</button>
</div>
</script>

关于css - 带有 ui-bootstrap-tpls-0.13 和 bootstrap 3.3.2 的 Ui-bootstrap-modal,angular 1.3.14 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31055949/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com