0
私はどのコントローラでもionic loader($ ionicLoading)にアクセスするためのファクトリサービスを作成しようとしていました。エラーが発生しました
"TypeError: $ionicLoading.show(...).then is not a function"
誰かが私が間違っているか、エラーが発生しているのを誰でも見ることができます!
コントローラ:
function ($scope, IonicLoader, $ionicLoading, $ionicPlatform) {
// load ionic loader
IonicLoader.show().then(function(){
// Do somenthing here
});
}
サービス:
var IonicLoader = angular.module('IonicLoader.service', []);
IonicLoader.factory('IonicLoader', ['$ionicLoading', function($ionicLoading){
// show the loader
function show(template, duration) {
// check and set template
var template = (typeof template == 'undefined' || template == false) ? '<ion-spinner icon="dots"></ion-spinner>' : template;
var duration = (typeof duration == 'undefined') ? 10000 : duration;
return $ionicLoading.show({
template: template,
animation: 'fade-in',
duration: duration,
}).then(function(){
console.log("The loading indicator is now displayed");
});
};
// hide the loader
function hide() {
return $ionicLoading.hide().then(function(){
console.log("The loading indicator is now hidden");
});
};
return {
show: show,
hide: hide
}
}])
私が見つけることができるものの、おそらく問題ではないものは次のとおりです:1. 'duration:duration、'は終わりのコンマを持つべきではありません。 2. angular.module( 'IonicLoader.service'、[]); 'イオン依存性を含むべきではありませんか? 3.あなたはモジュールを定義する 'var IonicLoader'を持っています。そしてコントローラに' IonicLoader'と同じ名前の別のパラメータを注入します。おそらく矛盾があります –
hello Ovidiu、助けてくれてありがとう。 私はあなたが言及したように試みましたが、それはまだ動作していません。私はそれが何であるか分かりません。 : -/ –
こんにちはOvidiu、もう一度ありがとう!私はその誤りの理由を知りました。それはionic-angular.jsバージョンに関するものです。 Ionic v1.3.2のための作品! –