How to call $cordovaDialogs on click


#1

I’m using the tabs template, trying to get ng-click on a button to show a ngCordova dialog. I’ve got the plugin installed and working when the controller fires. The button calls my $scope.alert(), but the $cordovadialogs.alert(“wow2!”); is not called because $cordovadialogs is undefined. Why does $scope not know about $cordovadialogs? I’m new to Angular… should this function be defined differently?

Code is as follows:
Send

.controller('FriendDetailCtrl', function ($scope, $stateParams, Friends, $cordovaDialogs) {
    $cordovaDialogs.alert('Wow!');
    $scope.friend = Friends.get($stateParams.friendId);

    $scope.alert = function () {
        alert('here');
        $cordovadialogs.alert("wow2!");//NOT WORKING
    };
})

#2

Are you sure the plugin is included? Where are you trying to run this code - in the browser or on the device?


#3

Yep plugin is working in controller. Running on device.


#4

And if you remove the alert call inside alert function whats happens?


#5

$cordovadialogs is not the same as $cordovaDialogs


#6

That did it! Thank you sir! I should have known that.

rafaellop: removing the js alert() had no effect.


#7

I’ve thought that there’s a mess with the same names of three different alert() calls. Haven’t noticed the misspelling. Congrats to craigj :slight_smile: