2015-11-30 48 views
0

所以我嘗試了一切,每一個例子,我絕對不知道什麼是錯的。每當我嘗試加載'$ uibModal'時,我都會收到錯誤,並且我所有的角碼都會中斷。如果我沒有正確加載它,那麼我得到$ uibModal.open錯誤。這是我的代碼。我目前的版本是0.14.3,我今天剛剛下載了這個文件。如果它很重要我的角應用程序是在軌道和即時通訊使用鮑爾導入一切。

我在我的js中加載的app.js文件。

var app = angular.module('planoxApp', 
['ui.router', 
'nya.bootstrap.select', // bootstrap select 
'ngAnimate', 
'ui.bootstrap', 
'main-directives',  
'templates', 
'color.picker', 
'xeditable', 
'restangular', 
'ngDragDrop', 
'angularFileUpload', 
'ngStorage' 

// 'mgcrea.ngStrap', 
// 'mgcrea.ngStrap.typeahead', 
// 'mgcrea.ngStrap.tooltip', 
// 'mgcrea.ngStrap.helpers.parseOptions', 

]) 

的CTRL裝載區域,這帶來了錯誤

[$注射器:unpr]未知提供商:$ uibModalProvider < - $ uibModal < - PhotoplanCtrl

app.controller('PhotoplanCtrl',['$http','$scope','$stateParams','$filter','$uibModal','$log', 
function($http,$scope, $stateParams,$filter,$uibModal,$log){ 

但如果我改變它也是

app.controller('PhotoplanCtrl',['$http','$scope','$stateParams','$filter','$log', 
function($http,$scope, $stateParams,$filter,$uibModal,$log){ 

錯誤消失了,在取而代之,我們得到,錯誤:$ uibModal.open不是一個函數。 (在 '$ uibModal.open', '$ uibModal.open' 是不確定的)

這裏是模態碼

var modalInstance = $uibModal.open({ 
    animation: $scope.animationsEnabled, 
    templateUrl: 'templates/photoplan/ModalPublish.html', 
    controller: 'ModalPublishCtrl' 
}); 

如果有人知道什麼是錯,任何幫助非常感謝。

+0

這似乎工作:http://plnkr.co/edit/MdQirCdgrkrUYjybtjRo?p=preview –

+1

你確定ui.bootstrap是在你的index.html加載嗎? 第二個錯誤是紅鯡魚。因爲您從依賴數組中刪除了$ uibModal,所以Angular實際上在您的代碼需要$ uibModal的地方注入$ log。 –

+0

所以我想在下面做一個更詳細的評論。但JC在正確的軌道上。我使用了Andy W plunker中的鏈接,並將它們插入到application.html.erb文件中,基本上是index.html,現在它正在工作。所以顯然它沒有正確加載到index.html文件中。我認爲它可能會在引導之前加載。所以我即將重新審視,然後發佈後續評論/回答 –

回答

0

好吧,首先,我的模態HTML你不能有NG控制器。顯然引導程序處理它,所以我的新的HTML看起來像。

<div class="modal-header" > 
      <h3 class="modal-title">Account Settings</h3> 
     </div> 
     <div class="modal-body"> 
      <ul> 
       <li> 
        <p>An option to chage password and account username </p> 
        <p>An option to change time settings </p> 
        <p> </p> 
       </li> 
      </ul> 
     </div> 
     <div class="modal-footer"> 
      <button class="btn btn-warning" type="button" ng-click="cancel()">Close</button> 
     </div> 

也出於某種原因,它不正確加載或者在我的導軌管道或角度,這是非常奇怪的。我可能會在github上報告該問題,但除此之外,我只是將CDN添加到我的index.html文件中,並開始正常工作。

相關問題