TypeError: Cannot read property 'show' of undefined


#1

I have a probleme with $ionicmodal wich doesn’t show up on my android device.

My controller is
`$ionicModal.fromTemplateUrl(’/templates/entrainement.html’, function(modal) {
$scope.modal = modal;
}, {
scope: $scope,
animation: ‘slide-in-up’
});

$scope.showAddEntrainementModal = function() {
    $scope.entrainement = {};
    $scope.entrainement.technique ={};
    $scope.entrainement.technique.serrage=0;
    $scope.action = 'Add';
    $scope.isAdd = true;
    console.log("add")
    $scope.modal.show();           
};` 

When i click on showAddEntrainementModal i have this message on my android device
"TypeError: Cannot read property ‘show’ of undefined
at Scope.$scope.showAddEntrainementModal (file:///android_asset/www/js/controllers.js:57:21)
at $parseFunctionCall (file:///android_asset/www/lib/angular/angular.js:12404:18)
at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:57606:9

Can you help me ?

Thanks


#2

Try on, this :

replace

$scope.modal.show();

by

$timeout(function(){ $scope.modal.show(); },0)


#3

Thanks, it works :slight_smile:


#4

Thanks mate! Appreciated.


#5

Thanks a lot buddy…


#6

Thanks bro!:grinning: