Ionic deviceready event versus ionicPlatform.ready


I am using cordovaVibration and cordovaSQLite plugins, and noticed what if i try to initiate them like that

$scope.toggle = function () {
    document.addEventListener('deviceready', function () {
        var db = $cordovaSQLite.openDB({name: "magic"});
    }, false);

Everything works fine (webrowser via ionic serve and built app on mobile, both good), but when i am trying to

    var db = $cordovaSQLite.openDB({name: "magic"});


    var db = $cordovaSQLite.openDB({name: "magic"});

I am getting error Uncaught TypeError: Cannot read property ‘openDatabase’ of undefined
and it’s same for vibration plugin.

.controller('flowCtrl', function ($scope, $cordovaSQLite, $ionicPlatform) { ...

$ionicPlatform dependency is added to controller, so i can’t imagine why ready method isn’t working properly