0

正如标题中提到的那样,模式不会显示出来。 窗体的内容通过formly加载,模板的内容似乎加载,但它只显示模式非常薄,与覆盖而不是内容。ui-bootstrap-modal with ui-bootstrap-tpls-0.13和bootstrap 3.3.2,angular 1.3.14不起作用

我有,我有一个主控制器:

$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> 

我的表单控件,像这样:

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

稍后编辑:

为了摆脱其他疑惑ourselfes,这里是从演示的代码:

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

后,稍后编辑:

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

文件夹结构:

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

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

+0

你看看[例子](http://angular-formly.com/#/example/integrations/ui-bootstrap-modal),它做到这一点? – kentcdodds

+0

@kentcdodds:检查编辑 – Gabriel

+1

似乎并不是这些版本的组合:http://jsbin.com/migico/1/edit?html,js,output。也许可以使用Plunker,CodePen,JSBin或类似的方法来重现问题,这样其他人可以帮助调试正在发生的事情。 – jme11

回答

2

模态模板不需要模态和模态对话层 - 它们将通过引导生成。

<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> 
+0

它仍然不起作用:( – Gabriel

+0

[fiddle](http://jsbin.com/risujodete/1/edit?html,js,output)请注意,你需要在templateUrl中匹配你的模板ID – Icycool

+0

我现在正在制作一个plunker – Gabriel