TypeError: Cannot read property 'show' of undefined

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

Try on, this :

replace

$scope.modal.show();

by

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

6 Likes

Thanks, it works :slight_smile:

Thanks mate! Appreciated.

Thanks a lot buddy…

Thanks bro!:grinning: