我正在开发依赖于的Ionicapp(2.0.0-rc0)angular 2.所以新的介绍ngModules包括在内.我在app.module.ts.下面添加我的.
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import { Users } from '../pages/users/users';
@NgModule({
declarations: [
MyApp,
Users
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
Users
]
})
export class AppModule {}
Run Code Online (Sandbox Code Playgroud)
是什么entryComponents在这里做?Components已定义于declarations.那么重复它们的必要性是什么?如果我在这里不包含组件会怎么样?
我是python的新手并在线尝试一些编码问题.我接受sys.sdnin很多接受输入.我想知道如何input()和sys.stdin在行动不同?
我正在一个名为foodsy的电子商务市场工作.我是stripe connect为了这个目的而使用的.使用连接帐户创建stripe-connect-omniauth.foodsy有几个客户.Sku在rails控制器中创建的订单
Stripe.api_key = "sk_test_o9YlLXk88Df4N2dmsdQtPEqZ"
Stripe::Order.create(
{:currency => 'usd',
:items => [
{
:type => 'sku',
:parent => "sku_7QKrhZJcqcuWBN"
}
] },
{ :stripe_account => "acct_17BTxDCioT3wKMvR" }
)
Run Code Online (Sandbox Code Playgroud)
它创建一个id为的订单 or_17BUNHCioT3wKMvREWdDBagG.
食品平台上的客户购买,
order=Stripe::Order.retrieve("or_17BUNHCioT3wKMvREWdDBagG",stripe_account: "acct_17BTxDCioT3wKMvR")
order.pay(customer: "cus_7QLGXg0dkUYWmK")
Run Code Online (Sandbox Code Playgroud)
但是这段代码会返回错误 No such customer: cus_7QLGXg0dkUYWmK (Stripe::InvalidRequestError).
客户存在,因为我可以在仪表板上看到他,源属性设置在条带上.那么为什么会出错呢?
我有一个ionic 2应用程序。它在选项卡视图中有一个选项卡。有两个选项卡。Home和Feed。该Feed页面有两个新选项卡Users和Freinds。Feed是Users页面的根,Users页面有一个ionViewDidEnter方法。
我面临的问题是当我在父选项卡Home和Feed. 如果我在两者之间切换Users并且Friends它有效。否则,只有父组件中的生命周期有效。
我该如何解决这个问题?有什么办法可以快速解决这个问题吗?
export class TabsPage {
tab1Root: any = FeedPage;
tab2Root: any = HomePage;
constructor(public navCtrl: NavController , public auth: Authentication , public book: Bookemon) {}
}
Run Code Online (Sandbox Code Playgroud)
tabs.html
<ion-tabs selectedIndex="0" tabsPlacement="top">
<ion-tab [root]="tab2Root" tabTitle="home" tabIcon="book"></ion-tab>
<ion-tab [root]="tab3Root" tabTitle="feed" tabIcon="compass"></ion-tab>
</ion-tabs>
Run Code Online (Sandbox Code Playgroud)
秒标签在 FeedPage
export class FeedPage {
tab1root = UsersPage; …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Ionic 2具有火种卡功能的应用程序。我想测试throwout当卡片拖动超过限制时发生的卡片事件。我正在使用摆动库。
主页.html
<div swing-stack #myswing1 [stackConfig]="stackConfig" id="card-stack">
<button ion-button icon-only *ngIf="hunts.length == 0" (click)="loadHunts()"><ion-icon name="refresh-circle"></ion-icon></button>
<ion-card swing-card #mycards1 *ngFor="let hunt of hunts" [navPush]="showHuntPage" [navParams]="{hunt: hunt}" >
<ion-card-header>
{{hunt.title}}
</ion-card-header>
<ion-card-content>
<div><img width="150" height="250" [src]="imageSource(hunt.picture_url)"></div>
<div>
{{hunt.clue}}
</div>
<div>
{{hunt.distance_from_user }} away
</div>
</ion-card-content>
</ion-card>
</div>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
每个ion-card都是throwable通过拖动。
我确实订阅了这样的throwing事件home.ts。
this.throwRightSub = this.swingStack.throwoutright.subscribe( (event: ThrowEvent) => {
let hunt = this.hunts.shift();
this.reviewHunt("accepted",hunt);
this.events.publish("hunt-accepted",hunt);
});
this.throwLeftSub = this.swingStack.throwoutleft.subscribe( …Run Code Online (Sandbox Code Playgroud) 我试图更好地了解Rust的寿命。
struct Name<'a> {
arg: &'a u8,
}
impl<'a> Name<'a> {
fn new1(arg: &'a u8) -> Name<'a> {
Name { arg }
}
fn new2<'b>(arg: &'b u8) -> Name<'b> {
Name { arg }
}
}
Run Code Online (Sandbox Code Playgroud)
是否有功能之间的差异new1和new2?我假设,如果会的问题arg是&self?在任何情况下都new2倾向于实现吗?
这几天困扰着我.我试过不同的方法.所以我会选择最简单的形式,这应该是有效但不是.
我有两个型号.Institute,和VirtualTour.
class Institute < ActiveRecord::Base
mount_uploader :virtual_images, VirtualPicUploader
has_many :virtual_tours, dependent: :destroy
accepts_nested_attributes_for :virtual_tours,allow_destroy: true
end
class VirtualTour < ActiveRecord::Base
belongs_to :institute
mount_uploader :image, VirtualPicUploader
end
Run Code Online (Sandbox Code Playgroud)
我很乐意devise去学院.这个更简单的版本没有考虑强参数,所以我会保持这样.
def account_update
default_params.permit!
end
Run Code Online (Sandbox Code Playgroud)
在编辑时会发生此上传,这就是使用account_update的原因.
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put , multipart: true }) do |f| %>
<%= f.fields_for :virtual_tours do |ff| %>
<%= ff.file_field :image, multiple: true %>
<%= ff.hidden_field :institute_id, value: f.object.id %>
<% end %>
<% end %> …Run Code Online (Sandbox Code Playgroud) 我有一个带有基本标签的离子2应用程序.
<ion-tabs selectedIndex="1">
<ion-tab [root]="tab1Root" tabTitle="hunts" tabIcon="book"></ion-tab>
<ion-tab [root]="tab2Root" tabTitle="home" tabIcon="home"></ion-tab>
<ion-tab [root]="tab3Root" tabTitle="hunting" tabIcon="locate"></ion-tab>
</ion-tabs>
Run Code Online (Sandbox Code Playgroud)
标签显示完美.但我想在标签之间转换时有一个滑动动画.也就是说,当我从中间选项卡按下最右边的选项卡时,中间选项卡应向左滑动,最右边的选项卡应从右侧滑入.这是一个基本的android动画.
我无法找到有关如何完成此任务的任何细节.这在Ionic(2.2.0)中仍然不可能吗?
我有一个我想测试的角度2服务功能。
service.ts
upload(){
let file = new Transfer();
file.upload(myfile).then( // my callback );
}
Run Code Online (Sandbox Code Playgroud)
我想Transfer使用进行模拟测试jasmine。我在我的尝试
sevice.spec.ts
import { TransferMock as Transfer } from '../mocks/mocks'嘲笑它。但这不起作用。这就是实例化我的测试的方式。
describe('authentication service' , () => {
beforeEach(() => {
auth = new Service(<any>new HttpMock(), <any>new StorageMock())
});
it('initialize authentication',() => {
expect(auth).not.toEqual(null);
auth.upload('file'); //it fails here
});
})
Run Code Online (Sandbox Code Playgroud)
编辑
Transfer没有注入服务。仅使用一种功能Transfer。因此,我认为不注入可以减少应用程序的初始加载时间(很高兴知道其他观点)。因此,我想知道是否可以通过这种方式来模拟它?
编辑
尽管我已经接受了Martin的回答,因为这是最佳实践,但是使用ionic-native插件时可能会发生一个问题。如果插件不具有浏览器支持,它可能会失败。在这种情况下,当我注入它时发生了错误FileTransfer is not defined。所以我又回来了,寻求建议。
我最近一直试图离子实验室试一试.从文档中,它就像命令一样简单ionic serve --lab.但这只显示普通ionic serve视图而不是android和iphone视图.我没有看到任何错误.
$ ionic serve -l
> ionic-hello-world@ ionic:serve /home/raj/ionic/bookemon
> ionic-app-scripts serve "--v2" "--lab" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"
[12:10:35] ionic-app-scripts 1.0.0
[12:10:35] watch started ...
[12:10:35] build dev started ...
[12:10:35] clean started ...
[12:10:35] clean finished in 6 ms
[12:10:35] copy started ...
[12:10:35] transpile started ...
[12:10:39] transpile finished in 3.58 s
[12:10:39] webpack started ...
[12:10:39] copy finished in 3.74 s
[12:10:46] webpack finished in 6.89 s
[12:10:46] …Run Code Online (Sandbox Code Playgroud) angular ×4
ionic2 ×4
rust ×2
carrierwave ×1
devise ×1
input ×1
jasmine ×1
python ×1
sys ×1
unit-testing ×1