2016-03-05 103 views
0

我正在一個離子應用,並且包括模態的視圖:

app.controller('StepMapCtrl', function($scope, $ionicModal){ 
     $ionicModal.fromTemplateUrl('template/modal.html', { 
     scope: $scope 
     }).then(function(modal) { 
     $scope.modal = modal; 
     }); 

     $scope.openModal = function() { 
     $scope.modal.show() 
     $scope.imgUrl = "http://placekitten.com/g/500/800" 
     } 
}); 

我下面這個模板:http://codepen.io/mikekoro/pen/dPYWvQ

當我打開網頁,我得到:

Error: [$injector:unpr] Unknown provider: $$qProvider <- $$q <- $ionicModal 
http://errors.angularjs.org/1.2.12/$injector/unpr?p0=%24%24qProvider%20%3C-%20%24%24q%20%3C-%20%24ionicModal 
    at ionic.bundle.js:9007 
    at ionic.bundle.js:12475 
    at Object.getService [as get] (ionic.bundle.js:12602) 
    at ionic.bundle.js:12480 
    at getService (ionic.bundle.js:12602) 
    at Object.invoke (ionic.bundle.js:12629) 
    at ionic.bundle.js:12481 
    at getService (ionic.bundle.js:12602) 
    at invoke (ionic.bundle.js:12629) 
    at Object.instantiate (ionic.bundle.js:12650) 

這是我的模式,模板/ modal.html

<ion-modal-view> 
    <ion-header-bar class="bar bar-header bar-stable"> 
     <h1 class="title">View Image</h1> 
     <button class="button button-clear button-primary" ng-click="modal.hide()">Close</button> 
    </ion-header-bar> 
    <ion-content class="padding" scroll="false"> 

     <ion-scroll zooming="true" direction="xy" delegate-handle="zoom-pane" class="zoom-pane" min-zoom="1" scrollbar-x="false" scrollbar-y="false"> 
     <img ng-src="{{imgUrl}}"> 
    </ion-scroll> 

    </ion-content> 
    </ion-modal-view> 

有人可以幫助我嗎?

回答

0

,我發現我的問題。

我在我的應用程序中添加了一箇舊的離子版本。

謝謝您的回覆

0
angular.module('ionicApp', ['ionic']) 
0

你的設置是什麼?你是否將你的代碼分成app.jscontrollers.js等?你忘了定義角模塊,還是忘了將它複製到上面的代碼片段中?

無論哪種方式,如果你使用app.controller...,你需要聲明的角模塊作爲一個變量,就像這樣:

var app = angular.module('ionicApp', ['ionic']); 

app.controller('StepMapCtrl', function($scope, $ionicModal){ 
     $ionicModal.fromTemplateUrl('template/modal.html', { 
     scope: $scope 
     }).then(function(modal) { 
     $scope.modal = modal; 
     }); 

     $scope.openModal = function() { 
     $scope.modal.show() 
     $scope.imgUrl = "http://placekitten.com/g/500/800" 
     } 
}); 
相關問題