我有一个使用AngularJS的phonegap应用程序.
在我的应用程序上,我使用NetworkStatus插件来确认手机正在使用的连接类型.
在我的根路由中,我正在解析对服务的调用,该服务调用DeviceService并且它负责访问navigator.network.connection.type并确定连接是打开还是关闭.resove将一个connectionState变量发送给控制器(通过路由解析功能),该变量声明连接状态.
在那条路线上,如果Connection不可用,我想抛出一个错误.
话虽如此,我的问题是在访问路由后触发了DeviceReady事件.所以我的路线决定无法完成连接验证.
如何同步我的角度应用程序只会在触发DeviceReady事件后启动?
嗨,我正在使用cordova开发混合应用程序.我试图使用CallLog插件访问在Android手机中错过的最后一个电话.这是我试过的,
1.I installed the plugin with this command cordova plugin add https://github.com/dalyc/Cordova-CallLog-Plugin.git.
2.I am using angularJS.I have this app.js.
var app=angular.module('lmp', ['ngCordova']);
app.controller('lmpctrl',['$scope', 'CallLogService', function($scope, CallLogService){
$scope.data = {};
$scope.callTypeDisplay = function(type) {
switch(type) {
case 1:
return 'Incoming';
case 2:
return 'Outgoing';
case 3:
return 'Missed';
default:
return 'Unknown';
}};
CallLogService.list(1).then(
function(callLog) {
console.log(callLog);
$scope.data.lastCall = callLog[0];
},
function(error) {
console.error(error);
});
}]);
app.factory('CallLogService', ['$q', function($q) {
return {
list : function(days) {
var q = $q.defer();
// days …Run Code Online (Sandbox Code Playgroud) 我有基于Cordova和Ionic的移动应用程序.在应用程序启动后加载的默认页面需要使用SQLLite插件.
https://github.com/brodysoft/Cordova-SQLitePlugin
问题是该视图包含
ng-init="setData()"
Run Code Online (Sandbox Code Playgroud)
这是调用控制器方法在哪里使用SQL Lite插件.并且因为在未初始化deviceready事件之前调用该方法(插件只能在deviceready事件之后初始化).
所以我尝试了这个解决方法:
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
db = window.sqlitePlugin.openDatabase({name:"callplanner"});
}
Run Code Online (Sandbox Code Playgroud)
但这不适合我.
所以我试过第二个解决方案
.factory('cordova', function () {
return {
test: function(){
document.addEventListener("deviceready", this.ready, false);
},
ready: function(){
alert("Ready");
db = window.sqlitePlugin.openDatabase({name:"callplanner"});
}
}
})
Run Code Online (Sandbox Code Playgroud)
并在控制器初始化我试过:
cordova.test();
Run Code Online (Sandbox Code Playgroud)
但这不起作用(在ng-init之后触发devicereadfy).
之后我发现了这篇文章:
http://java.dzone.com/articles/ionic-and-cordovas-deviceready
但我不明白如何在应用程序准备好之前放置"启动画面"以及如何设置超时.
有人知道如何解决这个问题?
非常感谢您的任何建议或帮助.
试图base href为angularjs html5网络应用程序设置正确的值在cordova中工作
最初$locationProvider.html5Mode(true)用于 <base href="/">:
在SO和ui-router 常见问题解答中尝试了一些替代方案:
<base href=".">使用html5模式根据这个答案:
Error: Failed to execute 'pushState' on 'History': A history state object with URL 'https://page/' cannot be created in a document with origin https://example.com<base href="./"> 使用html5模式:
Error: 10 $digest() iterations reached. Aborting!消息尝试使用这里提到的frankwallis解决方案,但没有帮助(相同的错误)没有base href用$locationProvider.html5Mode({enabled: true, requireBase: false});
我的app配置定义如下:
myApp.config(['$locationProvider', '$urlRouterProvider', '$stateProvider', …Run Code Online (Sandbox Code Playgroud) html5 angularjs cordova angular-ui-router angular-ui-router-extras
而不是离子我想使用cordova框架.
至今,
步骤1:
我创建了一个角度2应用程序.
第2步:
我已经创建了一个cordova应用程序并集成了角度2应用程序.
它运行成功.
第3步:
下一步是加载cordova.js文件
第4步:
在我的项目中添加cordova插件(如相机,设备分机).
第1步和第2步完成.
请帮我完成第3步和第4步.
当我调用插件时,它会抛出如下错误,