我正在为我的cordova 应用程序使用“imagepicker”插件,以便从移动图库中获取图像并使用它们。我正在 android 6.0 设备上测试我的应用程序,这就是问题所在,marshmallow Android 6.0 需要运行时许可,不像旧版本“它正在处理旧版本”,而是在 api 23 或更高版本上打开图库它立即关闭,应用程序崩溃。当我搜索时,我发现我需要获得许可才能这样做。所以我开始使用“Android 权限 Cordova 插件”并通过复制他们在此页面中提供的示例:https : //www.npmjs.com/package/cordova-plugin-android-permissions
这是:
var permissions = cordova.plugins.permissions;
permissions.hasPermission(permissions.CAMERA, checkPermissionCallback, null);
function checkPermissionCallback(status) {
if(!status.hasPermission) {
var errorCallback = function() {
console.warn('Camera permission is not turned on');
}
permissions.requestPermission(
permissions.CAMERA,
function(status) {
if(!status.hasPermission) errorCallback();
},
errorCallback);
}
}
Run Code Online (Sandbox Code Playgroud)
控制台总是说:'相机权限未打开'并且没有显示权限对话框。
然后我再次搜索并找到了这个已解决的问题和答案,所以我安装了“cordova-plugin-diagnostic”并尝试了以下代码:
function requestPermission(){
cordova.plugins.diagnostic.requestRuntimePermission(function(status){
switch(status){
case cordova.plugins.diagnostic.runtimePermissionStatus.GRANTED:
console.log("Permission granted (or already granted) - call the plugin");
// call SQLite plugin
break;
case cordova.plugins.diagnostic.runtimePermissionStatus.DENIED:
console.log("Permission denied - ask …Run Code Online (Sandbox Code Playgroud) 我是angular.js的新手,我正在按照大约一年前制作的教程,我正在尝试创建一个搜索功能,在Github.com中输入并搜索它.HTML代码是:
<!DOCTYPE html>
<html ng-app="github">
<head>
<script src="angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-controller="main">
<h1>{{message}}</h1>
<p> {{username}} </p>
<form name="search">
<input type="search" placeholder="enter name" ng-model="username">
<button type="submit" ng-click="search(username)">search</button>
</form>
<div>
<h1> {{user.login}} </h1>
<img src="http://www.gravatar.com/avatar/{{user.gravatar_id}}">
<p> {{user.type}} </p>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
和JS代码:
// Code goes here
(function () {
var app = angular.module("github", []);
var main = function ($scope, $http) {
var onComplete = function (response) {
$scope.user = response.data;
};
var onError = function (reasone) {
$scope.error = "no can"; …Run Code Online (Sandbox Code Playgroud) 我正在开发从在线服务器下载文件的 ionic 2 应用程序,我想将这些文件存储到本地存储(或我不知道的缓存)。
我知道我可以使用以下方法将数据存储到本地存储:
localStorage.setItem('key','value');
Run Code Online (Sandbox Code Playgroud)
但是如果是文件,特别是大文件,如何存储到本地存储呢?
注意:我正在使用 TypeScript。
我想阻止所有应用程序的页面在Framework 7中缓存。是否可以在此处添加任何选项?
var myApp = new Framework7({
material: true //enable Material theme
})
Run Code Online (Sandbox Code Playgroud)
或可以使我永久停止缓存的功能。
我是角度2和离子的新手,所以我会尽量缩短它:
<ion-card class="acc-page-card" *ngFor="let account of accounts">
<ion-card-content>
<!-- Add card content here! -->
<ion-item (click)="GoTo('AccountPage')">
<div class="acc-img" item-left>
<img src="{{account.img}}" alt="">
</div>
<div class="acc-details">
<span class="name">{{account.title}}</span>
<span class="title">{{account.link}}</span>
</div>
<div class="acc-icons" item-right>
<i *ngIf="valueFromArray" class="icomoon-Add-user-icon"></i>
<i *ngIf="valueFromArray" class="icomoon-Favorites-icon"></i>
</div>
</ion-item>
</ion-card-content>
</ion-card>
Run Code Online (Sandbox Code Playgroud)
其中'valueFromArray'是我想要从数组得到的值我循环尝试:
<i *ngIf="{{account.isFriend}}" class="icomoon-Add-user-icon active-icon"></i>
Run Code Online (Sandbox Code Playgroud)
这是错的.所以,如何使用数组中的值我在这样的情况下循环?对不起,我的英语不好 .
html ×3
cordova ×2
javascript ×2
typescript ×2
angular ×1
angularjs ×1
caching ×1
ionic2 ×1
permissions ×1