标签:browser rdo module blog 处理对象 依赖 htm markdown 真机
官网Doc - http://cordova.apache.org/docs/en/latest/guide/cli/index.html#add-plugins
ionic cordova plugin add cordova-plugin-camera
ionic依赖ng-cordova
直接使用CDN引入也可以: http://www.bootcdn.cn/ng-cordova/
引入位置是cordova之前, angularjs之后
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="https://cdn.bootcss.com/ng-cordova/0.1.27-alpha/ng-cordova.js"></script>
<script src="cordova.js"></script>
模块中加入ngCordova
依赖, 插件都需要设备ready之后才能正常工作, 在deviceready事件回调中使用, 如果浏览器调试的话还需要处理对象不存在的异常.
angular.module('myApp', ['ngCordova'])
.controller('LoginCtrl', ['$ionicPlatform', '$cordovaDevice', '$scope',
function($ionicPlatform, $cordovaDevice, $scope) {
$ionicPlatform.ready(function() {
// cordova plugin only work on real Device, not Broswer
if (window.device) {
// $scope.data.device = $cordovaDevice.getDevice();
// $scope.data.cordova = $cordovaDevice.getCordova();
$scope.data.devicetype = $cordovaDevice.getModel();
$scope.data.devicename = $cordovaDevice.getUUID();
$scope.data.platform = $cordovaDevice.getPlatform();
$scope.data.version = $cordovaDevice.getVersion();
}
});
}
]);
标签:browser rdo module blog 处理对象 依赖 htm markdown 真机
原文地址:http://www.cnblogs.com/wancy86/p/7896142.html