我有这样的架构:
var CustomUserSchema = new Schema({
role: [],
permissions: [],
});
Run Code Online (Sandbox Code Playgroud)
permissions field存储一个如下所示的字符串数组:
["Delete", "Show","Create"]
Run Code Online (Sandbox Code Playgroud)
而
role field存储一个如下所示的对象数组:
[
{
name:"admin",
priority:10,
permissions: ["Delete", "Show" , "update"]
},
{
name:"user",
priority:5,
permissions: ["Delete", "Show"]
}
]
Run Code Online (Sandbox Code Playgroud)
现在,我的要求是能够存储"显示"为默认值permissions字段中架构和存储"用户"作为默认值角色名称字段,优先级0的内部的priority内role场"秀"的permissions内role领域.
试着自己,我想出了这个:
var CustomUserSchema = new Schema({
role: [{
name: {type: String, default: 'user'},
priority:{ type: Number, default: 0 } ,
permissions: [{type:String, default:'Show'}]
}],
permissions: [{type:String, default:'Show'}]
});
Run Code Online (Sandbox Code Playgroud)
但它根本没有为字段分配默认值,而是为字段提供大小为0的数组.
以上架构似乎有什么问题?如何将这些存储为默认值?
我跟着这篇文章:
它在浏览器上工作正常,但是当我在Android手机中安装编译后的apk时,它会出现一个错误,表示Reference error : Connection is not defined.我在使用的行$cordovaNetwork.isOnline();
我一直在摸不着头脑,做了我应有的研究,尝试按照建议的顺序卸载和安装,但没有帮助.
帮我解决这个问题.这个问题可能不是代码的问题,可能需要一些聪明的修复才能使其正常工作.
这里正在讨论同样的问题,但我还没有真正理解给定的代码来自何处.
index.html:
<!DOCTYPE html>
<html ng-app="starter" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<!-- <link href="lib/ionic/css/angular-datepicker.min.css" rel="stylesheet"> -->
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
--> …Run Code Online (Sandbox Code Playgroud) 有什么区别
resolve在onFulfilledjavascript 中的承诺?
同样,有什么区别
reject和onRejected?简单来说,我只想问Promise.then(onsuccess, onreject)的onsuccess回调与Promise.resolve()有何不同?
我正在阅读 Daniel Parker 的《Javascript with Promises》。书上提到了两者,但我还没有意识到两者之间的区别。
在承诺中描述了当时的情况:
承诺.然后
Promise.then([onFulfilled], [onRejected]) 返回 Promise
Promise.then() 方法接受 onFulfilled 回调和 onRejected 回调。人们通常使用 Promise.catch() 注册 onRejected 回调,而不是将第二个参数传递给 then 。然后,该函数返回一个由 onFulfilled 或 onRejected 回调的返回值解析的 Promise。回调中抛出的任何错误都会拒绝带有该错误的新承诺。
还,
Promise.resolve
Promise.resolve([value|promise]) 返回promise Promise.resolve() 函数是一个方便的函数,用于创建已使用给定值解析的promise。如果您将 Promise 作为参数传递给 Promise.resolve(),则新的 Promise 与您提供的 Promise 绑定,并且它将相应地被履行或拒绝。
代码:
function settled(promises) {
var alwaysFulfilled = promises.map(function (p) {
return p.then(
function onFulfilled(value) {
return { state: 'fulfilled', value: value };
},
function onRejected(reason) { …Run Code Online (Sandbox Code Playgroud) 我想设计类似的东西
这是我到目前为止:
如何在离子中添加这些线?
这段代码是我到目前为止的代码:
如何在此处添加所需设计的CSS>
<ion-slide>
<div class="row">
<div class="col text-center">
<img src="img/icon1.png"></img>
<br>
Live Outlets </div>
<div class="col text-center">
<img src="img/icon2.png"></img>
<br>
Bills</div>
</div>
<div class="row">
<div class="col text-center">
<img src="img/icon3.png"></img>
<br>
Items Sold </div>
<div class="col text-center">
<img src="img/icon4.png"></img>
<br>
Discount</div>
</div>
<div class="row">
<div class="col text-center">
<img src="img/icon5.png"></img>
<br>
Customer </div>
<div class="col text-center">
<img src="img/icon6.png"></img>
<br>
Sale</div>
</div>
</ion-slide>
Run Code Online (Sandbox Code Playgroud) 我一直在使用离子和我的应用程序使用离子服务工作正常.
但是,一旦我在android中启动apk,它就会给出白色死亡屏幕并保持不变.
有什么方法可以调试我的Android平台的离子应用程序?
我曾经研究过一些关于调试的知识,并了解了有关chrome远程调试的知识.
手机显示在已连接的设备中,文档https://developer.chrome.com/devtools/docs/remote-debugging建议在webview类中添加上述代码行.我怎么做?离子中Web视图类的等价物是什么?
我听说人们将它添加到他们想要调试的html视图中,但这是否表明我需要将它添加到每个html页面以防我需要调试我的所有应用程序?在这种情况下,它听起来不是那么好的解决方案.
我可以请一点帮忙吗?
此外,如果有其他更简单的方法来调试离子应用程序,我真的很感激如果提到.
此外,我不拥有4.4 + ver的android.所以很高兴知道支持android 4.1的替代品.
<div class="card">
<div class="item item-thumbnail-left thumb-centre thumb-right">
<img src="img/carryout-icon.jpg"></img>
<img src="img/or.jpg"></img>
<img src="img/delivery-icon.jpg"></img>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.item.thumb-right img{
position: absolute !important;
top: 10px !important;
right: 20px !important;
margin-right: 20px !important;
max-width: 80px !important;
max-height: 80px !important;
width: 100% !important;
}
Run Code Online (Sandbox Code Playgroud)
我如何更新它以使图像位于中心
.item.thumb-centre img{
position: center !important;
top: 10px !important;
max-width: 80px !important;
max-height: 80px !important;
width: 100% !important;
}
Run Code Online (Sandbox Code Playgroud)
演示:
http://play.ionic.io/app/91deb2272019
编辑:中心图像的垂直对齐问题这就是它在控制台中的样子。
HTML:
<div ng-if="showSubHeader" class="topPull" draggable >
<button class="button-icon" on-swipe-down="changeSlide()"><img src="img/topImg.jpg"></button>
</div>
Run Code Online (Sandbox Code Playgroud)
指示:
.directive('draggable', function () {
return function(scope, element) {
// this gives us the native JS object
var el = element[0];
console.log(el)
el.draggable = true;
el.addEventListener(
'dragstart',
function(e) {
e.originalEvent.dataTransfer.effectAllowed = 'move';
// e.dataTransfer.setData('Text', this.id);
this.classList.add('drag');
return false;
},
false
);
el.addEventListener(
'dragend',
function(e) {
this.classList.remove('drag');
return false;
},
false
);
}
})
Run Code Online (Sandbox Code Playgroud)
错误:
Uncaught TypeError: Cannot read property 'dataTransfer' of undefined(anonymous function) @ controllers.js:12
app.js:19 Uncaught TypeError: Cannot …Run Code Online (Sandbox Code Playgroud) $scope.func1 = function() {
$http.get(url, {params}).success(function(result){
// code
}).error(function(error){
// error
})
}
$scope.func2 = function() {
$scope.func1();
// when http of func1 done executing, call following code
}
Run Code Online (Sandbox Code Playgroud)
如果http.get执行func1成功,如何检查func2 ?
我打算在离子应用程序启动时在默认页面中渲染选项卡和导航栏.
我已经能够从互联网上获取这些确切的功能,并且点击并尝试.但是我仍然不确定在应用程序的同一页面上使用导航栏和选项卡这一点很重要.
我有一个名为的文件menu.html,其中包含导航栏的代码.
它看起来像这样:
<ion-side-menus>
<ion-side-menu-content>
<ion-nav-bar class="bar-light">
<ion-nav-back-button>
</ion-nav-back-button>
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" menu-toggle="left">
</button>
</ion-nav-buttons>
<!-- <ion-nav-buttons side="right">
<button class="button button-icon button-clear ion-more" menu-toggle="right">
</button>
</ion-nav-buttons>
</ion-nav-bar>
-->
<ion-nav-buttons side="right">
<button class="button button-icon ion-more" ng-click="popover.show($event)"></button>
</ion-nav-buttons>
<ion-nav-view name="menuContent"></ion-nav-view>
</ion-side-menu-content>
<ion-side-menu side="left">
<ion-header-bar class="bar-assertive">
<h1 class="title">Left Menu</h1>
</ion-header-bar>
<ion-content>
<ul class="list">
<a href="#/menu/tabs" class="item" menu-close>Tabs</a>
<a href="#/menu/home" class="item" menu-close>About</a>
</ul>
</ion-content>
</ion-side-menu>
<!-- <ion-side-menu side="right">
<ion-header-bar class="bar-assertive">
<h1 class="title">Right menu</h1>
</ion-header-bar>
<ion-content>
<ul class="list" …Run Code Online (Sandbox Code Playgroud)