Search code examples
cordovaionic-frameworkvisual-studio-2015cordova-plugins

Cordova plugins undefined with IONIC framework


I'm in trouble and found no answer, my object windows.cordova.plugin this undefined need to access the keyboard, apparently my code is correct. I use Visual Studio 2015 and Last version cordova(5.3) and IONIC(1.1).

Thanks in advance

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>
    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="cordova.js"></script>
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/services.js"></script>
</head>
<body ng-app="starter">
    <ion-nav-bar class="bar-stable">
        <ion-nav-back-button>
        </ion-nav-back-button>
    </ion-nav-bar>
    <ion-nav-view></ion-nav-view>
</body>
</html>

APP.JS

angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if (window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if (window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})

.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider

  .state('login', {
      url: '/login',
      templateUrl: 'templates/login.html',
      controller: 'LoginCtrl'
  })

  .state('home-page', {
    url: '/home',
    templateUrl: 'templates/home.html',
    controller: 'HomeCtrl'
  })

  $urlRouterProvider.otherwise('/login');
});

Solution

  • I found the error, I created the project in the wrong way , creating a new project " cord apache " in Visual Studio 2015 community and added the " NuGet " the IONIC , then found the solution as follows I created a project by cmd for command iONIC "start ionic ... " . This generated a doubt can not create a direct IONIC project in Visual Studio 2015? equal the cord Apache ???