我正在尝试将以下Angular 1代码转换为Angular 2:
$http.jsonp('https://accounts.google.com/logout');
Run Code Online (Sandbox Code Playgroud)
它必须是JSONP请求才能跳过CORS策略问题.
当键盘显示时,我希望我的消息输入栏浮动在键盘上方,但看起来在Ionic 2中没有键盘附加指令(如v1)(可能在工作中?).有没有替代/解决方法?
目前的行为:
通缉行为:
这是我的消息输入栏的代码:
<ion-toolbar position="bottom" *ngIf="userIsAdmin">
<form (ngSubmit)="onSubmit(f)" #f="ngForm" class="message-form">
<ion-badge class="message-form-badge">Admin</ion-badge>
<ion-input type="text" placeholder="Type a message..." ngControl="messageInput"></ion-input>
<button type="submit" small class="message-form-button">Send <ion-icon name="send"></ion-icon></button>
</form>
</ion-toolbar>
Run Code Online (Sandbox Code Playgroud) 我需要通过jQuery AJAX 从Upwork API请求一个JSONP文件.Upwork API使用OAuth 1.0身份验证.
我是Oauth的新手,但在过去的几天里一直在阅读它,我一般都了解它是如何工作的,但在这个特定的场景/环境中实现它非常困难.几天来一直在敲我的头,而Upwork API的支持并没有多大帮助:(
我需要通过OAuth 1.0中的所有必要步骤,并获取与请求网址一起传递的OAuth参数.请帮忙!
这是我到目前为止所做的:
// My Upwork API key and secret
var api_key = 'xxx',
api_secret = 'xxx';
// TO-DO
// OAuth 1.0 authentication
// TO-DO
// required oauth parameters
// https://developers.upwork.com/?lang=node#authentication_required-oauth-10-parameters
var oauth_consumer_key = '',
oauth_signature = '',
oauth_nonce = '',
oauth_signature_method = '',
oauth_timestamp = '',
oauth_token = '';
// Compose request url with required oauth parameters
var url = "https://www.upwork.com/api/profiles/v2/search/jobs.json?q=java&callback=?";
url += "&oauth_consumer_key="+oauth_consumer_key;
url += "&oauth_signature="+oauth_signature;
url += …
Run Code Online (Sandbox Code Playgroud) 我有这个对象数组:
var arr = [
{
name: 'John',
contributions: 2
},
{
name: 'Mary',
contributions: 4
},
{
name: 'John',
contributions: 1
},
{
name: 'Mary',
contributions: 1
}
];
Run Code Online (Sandbox Code Playgroud)
...我希望合并重复,但总结他们的贡献.结果如下:
var arr = [
{
name: 'John',
contributions: 3
},
{
name: 'Mary',
contributions: 5
}
];
Run Code Online (Sandbox Code Playgroud)
我怎么能用JavaScript实现这一目标?
这是期望的效果:
这就是我提出的:http://jsfiddle.net/nunoarruda/3j6782js/
// table
.sw-table {
border-collapse: separate;
thead {
background-color: $orange;
color: $white;
font-size: 15px;
th {
border: none !important;
font-weight: 600;
padding-top: 5px !important;
padding-bottom: 5px !important;
margin: 30px 27px !important;
&:first-child {
border-top-left-radius: 10px;
padding-left: 25px;
}
&:last-child {
border-top-right-radius: 10px;
}
}
}
tbody {
color: $black;
tr {
td {
border-color: $greyish;
padding-top: 10px !important;
padding-bottom: 10px !important;
}
td:first-child {
border-left: 1px solid $greyish;
padding-left: 25px;
}
td:last-child {
border-right: 1px …
Run Code Online (Sandbox Code Playgroud) 我想使用Google People API检索我的联系人姓名,电子邮件地址和电话号码,我正在使用他们的试用版!用于测试API的工具.
将被取回的姓名,但不是电子邮件地址和电话号码.我想我正在做的一切正确.我已通过适当的范围和选定的字段进行了适当的身份验证.
难道我做错了什么?或者这可能是谷歌方面的一个问题?
我在一个真实的项目中有一个真实的场景,我需要2个服务来访问彼此的属性和/或方法.我不是Angular专家所以它可能吗?
我试过了,它失败了.这是我的尝试:
app.component.ts
import { Component } from '@angular/core';
import { FirstService } from './first.service';
import { SecondService } from './second.service';
@Component({
selector: 'my-app',
template: '<h1>Hello world!</h1>',
providers: [FirstService, SecondService]
})
export class AppComponent {
constructor(public firstService: FirstService, public secondService: SecondService) {
console.log(firstService.foo);
console.log(secondService.bar);
}
}
Run Code Online (Sandbox Code Playgroud)
first.service.ts
import { Injectable } from '@angular/core';
import { SecondService } from './second.service';
@Injectable()
export class FirstService {
foo: string = 'abc';
constructor(public secondService: SecondService) {
this.foo = this.foo + this.secondService.bar;
}
}
Run Code Online (Sandbox Code Playgroud)
second.service.ts …
我刚刚遇到一个用例,它对col
标记的样式很有用:
在这种特殊情况下,我想设置color
"帖子名称"列,但事实证明它不起作用或不允许.但是background-color
允许虽然这让我想知道为什么color
不是.
我检查了规范(http://www.w3.org/TR/html5/tabular-data.html#the-col-element)但我找不到任何有用的信息.我知道如何只用CSS做同样的效果,我只是想知道是否有人知道为什么会发生这种情况?
我想在离子内容上有或没有滚动条时隐藏或显示元素。更具体地说,我想在没有滚动条时显示一个按钮(以在列表中加载更多项目)并将其隐藏在有滚动条的地方(因此更多项目的加载是通过 ion-infinite-scroll 完成的)。
我的 Ionic 应用程序也将部署到桌面,因此大屏幕用户最初不会看到滚动条,因此不会触发 ion-infinite-scroll。
这是一个演示该问题的演示:
主页.html
<ion-header>
<ion-toolbar>
<ion-title>
Ionic header
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<div class="ion-padding">
<p *ngFor="let item of itemList">{{ item }}</p>
<!-- How to hide this button when ion-content has a scrollbar? -->
<!-- *ngIf="???" -->
<ion-button (click)="incrementItemList(5)">Load more items</ion-button>
</div>
<ion-infinite-scroll (ionInfinite)="loadMoreItems($event)">
<ion-infinite-scroll-content loadingSpinner="crescent"></ion-infinite-scroll-content>
</ion-infinite-scroll>
</ion-content>
<ion-footer>
<ion-toolbar>
<ion-title>
Ionic footer
</ion-title>
</ion-toolbar>
</ion-footer>
Run Code Online (Sandbox Code Playgroud)
主页.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage { …
Run Code Online (Sandbox Code Playgroud) 我在亚速尔群岛,昨天(2016年10月30日)时区已经从GMT + 0000(AZOST)变为GMT-0100(AZOT).
现在new Date('2016-10-31')
回来了Sun Oct 30 2016 23:00:00 GMT-0100 (AZOT)
:
这是JavaScript Date对象的正确行为吗?我期待输出Mon Oct 31 2016...
我想展开这样的对象...
var obj2 = {
"firstName": "John",
"lastName": "Green",
"car.make": "Honda",
"car.model": "Civic",
"car.revisions.0.miles": 10150,
"car.revisions.0.code": "REV01",
"car.revisions.0.changes": "",
"car.revisions.1.miles": 20021,
"car.revisions.1.code": "REV02",
"car.revisions.1.changes.0.type": "asthetic",
"car.revisions.1.changes.0.desc": "Left tire cap",
"car.revisions.1.changes.1.type": "mechanic",
"car.revisions.1.changes.1.desc": "Engine pressure regulator",
"visits.0.date": "2015-01-01",
"visits.0.dealer": "DEAL-001",
"visits.1.date": "2015-03-01",
"visits.1.dealer": "DEAL-002"
};
Run Code Online (Sandbox Code Playgroud)
...变成具有嵌套对象和数组的对象,如下所示:
{
firstName: 'John',
lastName: 'Green',
car: {
make: 'Honda',
model: 'Civic',
revisions: [
{ miles: 10150, code: 'REV01', changes: ''},
{ miles: 20021, code: 'REV02', changes: [
{ type: 'asthetic', desc: 'Left tire cap' }, …
Run Code Online (Sandbox Code Playgroud) angular ×4
javascript ×4
typescript ×4
arrays ×2
css ×2
html ×2
ionic2 ×2
ajax ×1
angularjs ×1
api ×1
asynchronous ×1
cordova ×1
css3 ×1
date ×1
datetime ×1
ecmascript-6 ×1
flatten ×1
google-api ×1
html5 ×1
ion-content ×1
ionic4 ×1
jquery ×1
jsonp ×1
oauth ×1
object ×1
recursion ×1
sass ×1
scrollbar ×1
time ×1
timezone ×1
w3c ×1