当我这样编写自己的自定义组件时:
import { Component } from '@angular/core';
@Component({
selector: 'deletableItem',
template: `
<ion-checkbox item-right></ion-checkbox>
`
})
export class DeletableItem {
constructor() {}
}
Run Code Online (Sandbox Code Playgroud)
并在一些html视图中使用它:
<ion-content padding>
<ion-list>
<ion-item *ngFor="let bill of bills" (click)="openEdit(bill)">
<ion-label text-left>{{bill.name}}</ion-label>
<deletableItem></deletableItem>
</ion-item>
</ion-list>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
看起来比立即将其放在父组件的组件视图中更糟糕:
<ion-content padding>
<ion-list>
<ion-item *ngFor="let bill of bills" (click)="openEdit(bill)">
<ion-label text-left>{{bill.name}}</ion-label>
<ion-checkbox item-right></ion-checkbox>
</ion-item>
</ion-list>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
所有这些都是因为angular将这个组件的html代码包装到html标签中。因此,我们失去了离子成分的强度(制备的CSS)。请不要建议使用归因组件分配,例如:
<ion-checkbox item-right deletableItem></ion-checkbox>
Run Code Online (Sandbox Code Playgroud)
因为这只是简单的例子。
在不丢失准备好的CSS的情况下,编写带有离子成分的自定义成分的最佳方法是什么?
安装Ionic最后版本3.1.2后,我尝试添加Native Geolocation插件,我得到以下内容:
ionic plugin add cordova-plugin-geolocation
Run Code Online (Sandbox Code Playgroud)
插件命令已重命名.要了解更多信息,请运行:
ionic cordova plugin --help
Run Code Online (Sandbox Code Playgroud)
我将不胜感激任何帮助.
提前致谢
我正在使用Ionic应用程序中的聊天应用程序的最后一项功能,在该功能中,我试图无限滚动到两个人之间创建的“第一条”消息,这与您使用的任何其他聊天应用程序类似。 Facebook,Skype,Slack等
我遇到的问题是几件事。
当我在<ul>容纳所有消息的上方添加无限滚动代码时,会得到一个200px高的空白(我认为这是加载微调器的原因)。这是我的代码:
<ion-infinite-scroll (ionInfinite)="scrolled($event)"
threshold="10px"
position="top">
<ion-infinite-scroll-content></ion-infinite-scroll-content>
</ion-infinite-scroll>
<ul>
<li *ngFor="let message of messages; let i = index">
... other code to build the message
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)我的聊天设置只捕获特定会话的前10条消息,其想法是,一旦它成为“顶部”无限滚动区域,它就会查询下10条消息,等等。问题是,当聊天加载时,在滚动条向下滚动到屏幕底部以显示最后发送的消息之前,会有片刻的暂停。但是,在那一瞬间,滚动条已经位于页面顶部,这似乎表明<ion-infinite-scroll>要启动该scrolled()功能。
还有其他人遇到过这样的事情吗?呈现页面后,消息将异步加载,因此,我正在尝试找出防止<ion-infinite-scroll>页面加载时触发的最佳方法。我在这里缺少简单的东西吗?
提前致谢!:)
我正在从这里查看Ionic Config Service:https://ionicframework.com/docs/api/config/Config/
我想使用Config功能来设置全局配置变量(在我的情况下为API密钥)。我正在努力使其工作。
每当我打电话给:
config.set('ios', 'green', 'light');
Run Code Online (Sandbox Code Playgroud)
它告诉我未定义config。但是我无法将Config导入为
import { Config } from 'ionic-angular';
Run Code Online (Sandbox Code Playgroud)
不起作用。我以为它可以像平台服务一样导入,但似乎不像。该文档缺少更多信息。
任何帮助表示赞赏。
我刚刚从版本4到5更新了离子应用中的角度.我有一些搜索FormControl输入,允许用户通过ajax请求搜索数据库.我使用debounceTime()方法来延迟ajax搜索请求,但在角度升级之后,此方法不再可用.我删除了这个方法调用,但现在在android上的每个用户键上都会发出一个新请求.
有没有其他方法来实现这种延迟?
this.searchControl.valueChanges
.debounceTime(2000)
.subscribe(search => this.getCities(search));
Run Code Online (Sandbox Code Playgroud) 问:(ionInput)和之间有什么区别(ionChange)?在哪种情况下,我应该选择其中一个?
我已经尝试了如下所示的两个代码,并且给出了与预期相同的结果。
使用ionInput事件的示例代码
<ion-searchbar type="text" maxlength="18" placeholder="Search" debounce="0"
[(ngModel)]="usernameText" (ionInput)="findUserWithUsername()"></ion-searchbar>
Run Code Online (Sandbox Code Playgroud)
使用ionChange事件的示例代码
<ion-input type="text" maxlength="18" placeholder="Search" clearInput
[(ngModel)]="usernameText" (ionChange)="findUserWithUsername()"></ion-input>
Run Code Online (Sandbox Code Playgroud) 我正在尝试通过CLI构建我的Ionic 3应用程序ionic cordova build android --prod.
以前这个命令没有任何问题,现在它正在冻结这webpack一步,就在之后copy finished.
# npm run ionic:build --prod
> ionic-app@ ionic:build /Users/personal/Documents/ionic-app
> ionic-app-scripts build
[10:47:11] ionic-app-scripts 3.1.9
[10:47:11] build prod started ...
[10:47:11] clean started ...
[10:47:11] clean finished in 1 ms
[10:47:11] copy started ...
[10:47:11] deeplinks started ...
[10:47:11] deeplinks finished in 327 ms
[10:47:11] ngc started ...
[10:47:29] ngc finished in 17.34 s
[10:47:29] preprocess started ...
[10:47:29] preprocess finished in 1 ms
[10:47:29] webpack …Run Code Online (Sandbox Code Playgroud) 我正在使用带有刷新令牌的令牌身份验证的应用程序。我已经在Web应用程序的angular v1中成功实现了身份验证和刷新令牌。在使用angular v5的ionic 3应用程序中,我还实现了该过程。它通过刷新令牌成功获取了新令牌。但是问题是,它没有再次调用最后一个请求。
这是我的Http拦截器实现。
@Injectable()
export class HttpsRequestInterceptor implements HttpInterceptor {
isRefreshingToken: boolean = false;
tokenSubject: BehaviorSubject<string> = new BehaviorSubject<string>(null);
constructor(
private injector : Injector
) {
}
addToken(req: HttpRequest<any>, token: string): HttpRequest<any> {
return req.clone({ setHeaders: { Authorization: 'Bearer ' + token }})
}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpSentEvent | HttpHeaderResponse | HttpProgressEvent | HttpResponse<any> | HttpUserEvent<any>> {
const authenticationService = this.injector.get(AuthenticationService);
let user : AuthenticatedUser = authenticationService.getUser1();
console.log("token", (user)? user.token : null);
let dupReq: HttpRequest<any>;
if (user …Run Code Online (Sandbox Code Playgroud) typescript ionic-framework angular-http-interceptors ionic3 angular
当我尝试使用以下代码在设备中运行应用程序时:
ionic cordova build android
它会生成一个APK,并且我已将其安装在设备中。当我使用此代码进行构建时,广告可以正常工作:
showAd() {
const bannerConfig: AdMobFreeBannerConfig = {
isTesting: true,
autoShow: true
};
this.admobFree.banner.config(bannerConfig);
this.admobFree.banner.prepare()
.then(() => {
// banner Ad is ready
// if we set autoShow to false, then we will need to call the show method here
})
.catch(e => console.log(e));
}
当我使用此其他代码进行构建时,广告不会显示:
showAd() {
const bannerConfig: AdMobFreeBannerConfig = {
id: 'MY-ID-FROM-ADMOB',
isTesting: false,
autoShow: true
};
this.admobFree.banner.config(bannerConfig);
this.admobFree.banner.prepare()
.then(() => {
// banner Ad is ready
// if we set autoShow …
我正在使用IONIC并从服务器中检索URL,使用<p>标签时可以看到URL ,如下所示:
<p>{{URL}}</p>
Run Code Online (Sandbox Code Playgroud)
但是当我尝试以下操作时:
<video width="320" height="240" controls>
<source src="{{URL}}" type="video/mp4">
</video>
Run Code Online (Sandbox Code Playgroud)
我收到一个错误(Get请求错误),提示“不安全的网址”
我发现有人建议sanitizer.bypassSecurityTrustResourceUrl像在此页面中那样使用,但不幸的是,它对我不起作用
注意:视频位于项目文件夹中,并且URL是从数据库中检索的。
如何启用<video>标签以播放项目目录中的视频?
ionic3 ×10
angular ×5
ionic2 ×4
typescript ×4
admob ×1
cordova ×1
geolocation ×1
html5 ×1
rxjs ×1