I'm new in ionic and I want to use Corodova Diagnostic plugin in my ionic project. I don't know how to use plugins in ionic. I've added this plugin using this command.

```
 $ cordova plugin add cordova.plugins.diagnostic

```

I can see this plugin in my list using 

```
 $ cordova plugins ls

```

now i have a seperate controller file, i am post its code here, when i try to use this , it give error, cordova is

```
 angular.module('timetools_controllers', ['ui.utils', 'ionic','cordovaGeolocationModule'])

.controller('TimetoolsCtrl', ['$scope', '$http', '$localstorage', '$ionicPopup', function ($scope, $http, $localstorage, $ionicPopup) {

    /*=================================================================================*/
    // ABFRAGE OB TRACK & SHARE AKTIV IST
    /*=================================================================================*/
    var fdappAuth = $localstorage.getObject('fdappAuth');

    $http({
        method: 'GET',
        url: 'http://app.flugdeck.com/options.php?apikey=7ksmewzSUd2asSA0384cosb!2w3SloE&do=get&optid=110&userId=' + fdappAuth.fdappUserId + '&userPwHash=' + fdappAuth.fdappUserPw,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
        }
    })
        .success(function (data, status) {
            // Verarbeitet die Daten und setzt diese zur Anzeige in die scopes
            console.log("Optionsabfrage für Track & Share läuft");

            $scope.optentry = data[0];
            $scope.optentry.opt_110 = data[0].opt_110;

            if ($scope.optentry.opt_110 == 1) {
                $scope.isTrackShareActive = "Tracking ";
                $scope.cssClass = "Tracking";
            } else {
                $scope.isTrackShareActive = "Tracking ";
                $scope.cssClass = "Tracking";
            }
        });

    $scope.saveOffBlockTime = function () {
        var datum = new Date();
        console.log("Datums-String: " + datum);

        // Erstelle das Datum und Poste das
        if ($scope.OffBlockRunAlready === true) {

        } else {
            // Setzt das Datum
            $scope.OffBlockTime = datum;

            $scope.OffBlockRunAlready = true;

            if ($scope.optentry.opt_110 == 1) {
                /***********************/
                // GPS TEST CODE CORDOVA
                /***********************/
                alert("GPS TEST");
                 cordova.plugins.diagnostic.isLocationEnabled(function(enabled){
                    console.log("Location is " + (enabled ? "enabled" : "disabled"));
                }, function(error){
                    console.error("The following error occurred: "+error);
                });

            }

        }
    }; // saveOffBlockTime

}]) ;// Ende .controller('TimetoolsCtrl'...

```

but it give following error in console.

```
 ReferenceError: cordova is not defined

```

Can anybody help me please?

my Index.html

```
 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>

<!-- build:css dist_css/styles.css -->
<link href="css/ionic.app.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- endbuild -->

<script src="http://maps.google.com/maps/api/js"></script>
<!-- build:js dist_js/modules.js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/underscore/underscore-min.js"></script>
<script src="lib/ngmap/build/scripts/ng-map.min.js"></script>
<script src="lib/moment/min/moment.min.js"></script>
<script src="lib/angular-moment/angular-moment.min.js"></script>
<script src="lib/angular-md5/angular-md5.min.js"></script>
<script src="lib/angular-base64/angular-base64.min.js"></script>
<script src="lib/angular-cordova-geolocation/cordovaGeolocationModule.js">      </script>
<script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
<!-- endbuild -->
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

<!-- build:js dist_js/app.js -->
<script src="dist/dist_js/app/app.js"></script>
<script src="dist/dist_js/app/directives.js"></script>
<script src="dist/dist_js/app/controllers.js"></script>
<script src="dist/dist_js/app/templates.js"></script>
<script src="dist/dist_js/app/services.js"></script>
<script src="dist/dist_js/app/config.js"></script>
<script src="dist/dist_js/app/filters.js"></script>
<script src="js/mymodules.js"></script>
<script src="lib/ui-utils.min.js"></script>
<script src="js/controller_flightlog.js"></script>
<script src="js/controller_timetools.js"></script>
<script src="js/controller_infotools.js"></script>
<script src="dist/dist_js/app/factories.js"></script>
<!-- endbuild -->
</head>

<body ng-app="your_app_name">
<ion-nav-view></ion-nav-view>
</body>
</html>

```