我想在离子输入中始终显示精确到两位小数的数字.以便:
1.01
1.10
1.20
1.23
Run Code Online (Sandbox Code Playgroud)
不显示为:1.1和1.2,但显示为1.10和1.20
我的模型是:
export class HomePage {
public myValue:number;
}
Run Code Online (Sandbox Code Playgroud)
使用html文件如下:
<ion-content padding>
<h3>Hello</h3>
<ion-row margin-right="50px" margin-left="50px">
<ion-input type="number" ng-pattern="/^[0-9]+(\.[0-9]{1,2})?$/" step="0.01"
[(ngModel)]="myValue" placeholder="0.00"></ion-input>
</ion-row>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
<ion-input type="number" step="0.01"
[(ngModel)]="myValue" placeholder="0.00"></ion-input>
Run Code Online (Sandbox Code Playgroud)
它适用于Web浏览器(MacOS,55.0.2883.95(64位)),但不适用于Android(在7.1上测试)
有什么建议?
几个小时以来,我一直在我的项目中寻找解决这个问题的方法无济于事.我已经阅读了许多其他"无法读取属性......未定义"的帖子,但似乎无法找到我的解决方案.
以下是我项目中的相关代码.
这是一个Ionic 2/Apache Cordova项目,下面的页面是应用程序的登录页面.它不是核心应用程序组件之一,它只是一个常规页面.
出于某种原因,在onSignIn()方法中没有识别NavController,但我不知道为什么.我在构造函数中注入了NavController,看起来我没有遵循我所知道的任何已知过程,但它每次都失败了.
import firebase from 'firebase';
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { HomePage } from './../home/home';
var provider = new firebase.auth.FacebookAuthProvider();
@Component({
selector: 'page-signin',
templateUrl: 'signin.html',
})
export class SignInPage {
constructor(public navCtrl: NavController, public params: NavParams) {}
onSignIn() {
firebase.auth().signInWithPopup(provider).then(function(result) {
console.log(result.credential.accessToken);
console.log(result.user.displayName);
this.navCtrl.setRoot(HomePage);
}).catch(function(error) {
console.log(error.message);
});
}
}
Run Code Online (Sandbox Code Playgroud) 当我应对并移动到具有离子3的mac时,我在我的linux任务中有了我的离子2项目.
所以我创建了一个新项目,用新项目替换了页面,提供了components文件夹,我得到了错误就像cannot find module "ionic-native"将我的插件导入app.modulte.ts文件后我得到的错误就是'类型'任何'不是构造函数功能类型
我的终端显示
17:39:48] typescript: node_modules/@ionic-native/app-version/index.d.ts, line: 25
Type 'any' is not a constructor function type. [17:39:48] typescript: node_modules/@ionic-native/geolocation/index.d.ts, line: 127 [17:39:48] typescript: node_modules/@ionic-native/google-analytics/index.d.ts, line: 30 [17:39:48] typescript: node_modules/@ionic-native/network/index.d.ts, line: 49 [17:39:48] typescript: node_modules/@ionic-native/sms/index.d.ts, line: 41 [17:39:48] typescript: node_modules/@ionic-native/social-sharing/index.d.ts, line: 29 [17:39:48] typescript: node_modules/@ionic-native/sqlite/index.d.ts, line: 115
L25: export declare class AppVersion extends IonicNativePlugin {
Type 'any' is not a constructor function type.
L127: export declare class Geolocation extends IonicNativePlugin {
Type 'any' is not a …Run Code Online (Sandbox Code Playgroud) 我正在构建一个应用程序来显示书籍的内容.我在这个应用程序中有3个页面:
第1页.链接到章节的按钮列表; (ChaptersPage)
第2页.链接到章节页面的按钮列表; (PagesPage)
第3页.页面内容; (PageContentPage)
页面1和2位于选项卡内,因此当用户选择一个章节时,他会转到下一个选项卡,然后选择该章节的页面,然后获取页面内容.选项卡将如下所示:
所有页面和章节都在他自己的文件夹中.我的app文件夹如下所示:
src
|_ app
|_ assets
|_ icon
|_ images
|_ chapters
|_ 1
|_page_1.txt
|_page_2.txt
|_ 2
|_page_1.txt
|_page_2.txt
|_ 3
|_page_1.txt
|_page_2.txt
|_ ...
|_ pages
|_ services
|_ ...
Run Code Online (Sandbox Code Playgroud)
首先,当用户选择章节时,我需要查看章节文件夹中有多少页面,因此我可以列出正确数量的按钮.我正在尝试使用离子原生文件插件,但我没有成功.使用文件插件文档上的示例我总是得到"目录不存在":
this.file.checkDir(this.file.applicationDirectory, 'assets/chapters/2').then(_ =>
console.log('Directory exists')
).catch(err => console.log('Directory doesnt exist'));
Run Code Online (Sandbox Code Playgroud)
所以,我的问题是:如何读取章文件夹中有多少文件?之后,如何获取page.txt的内容?
我不确定我是否只面临一个问题ionic cordova run android --prod而我的ionic cordova run android工作正常.
错误:
Error: Cannot determine the module for class OverlayPortal in /Users/gopi/Documents/bos/hybrid-app/node_modules/ionic-angular/es2015/components/app/overlay-portal.d.ts! Add OverlayPortal to the NgModule to fix it.
Cannot determine the module for class IonicApp in /Users/gopi/Documents/bos/hybrid-app/node_modules/ionic-angular/es2015/components/app/app-root.d.ts! Add IonicApp to the NgModule to fix it.
Cannot determine the module for class ClickBlock in /Users/gopi/Documents/bos/hybrid-app/node_modules/ionic-angular/es2015/components/app/click-block.d.ts! Add ClickBlock to the NgModule to fix it.
Cannot determine the module for class Slides in /Users/gopi/Documents/bos/hybrid-app/node_modules/ionic-angular/es2015/components/slides/slides.d.ts! Add Slides to the NgModule to …Run Code Online (Sandbox Code Playgroud) 我需要一个没有完整尺寸(80%宽度,<60%高度,居中)的模态页面来选择一些项目,如警报控件.如何为这种情况实现CSS?
我想padding从我的离子项目中删除,以便它可以占据整个width页面。
请在开发工具中查看padding离子项目的周围。
<ion-content padding>
<ion-list>
<ion-item>
<ion-thumbnail>
<img class="imgmg" src="...">
</ion-thumbnail>
<h2>Text</h2>
</ion-item>
</ion-list>
</ion-content>Run Code Online (Sandbox Code Playgroud)
ion-item的填充为16px,当我检查ion-item时,也在class =“ scroll-content”上,我在检查器中找到了scss
ion-app.md [padding] .scroll-content {
padding: 16px;
}
Run Code Online (Sandbox Code Playgroud)
如果删除此填充,则ion-item可以通过删除此填充来占据整个宽度,但是当我在scss文件中使用此填充时,不会删除该填充。
我在离子存储方面遇到问题。
当我登录我的应用程序时,它保存了一些配置对象。在我的最后一次检查是在IndexedDb上。
但是,如果我保存任何文件更改或只是刷新页面,有时它就会从IndexedDb切换到Web SQL。
我的所有数据都“丢失了”,因为数据库是一个全新的数据库。
任何人都知道为什么会发生或如何解决。
这是我的app.module存储设置
IonicStorageModule.forRoot({
name: '__cds',
driverOrder: ['indexeddb', 'sqlite', 'websql']
})
Run Code Online (Sandbox Code Playgroud)
编译为App时,恐怕会对此产生影响。到目前为止,我只从事浏览器开发
我就是这样设置的
//响应是我从http调用接收到的对象
this.storage.set('cds', response).then(() => {
this.goHome();
});
Run Code Online (Sandbox Code Playgroud)
我就是这样
this.storage.get('cds').then(cds => {
this.variable = JSON.parse(cds);
});
Run Code Online (Sandbox Code Playgroud)
看,这不是在单个数据库上“维护”存储
我正在尝试拍照,并使用ionic 3 App for iOS中的tesseract OCR引擎对其进行分析。我正在尝试在iPhone 8 iOS 11.2.6上运行它。不幸的是Xcode,拍照后出现错误,并且应用程序崩溃:
NSURLConnection以错误-代码-1002完成, 并且还警告:清理不安全的URL值资产-library://asset/asset.JPG?id = A791150A-3E89-400E-99D3-E7B3A3D888AA&ext = JPG
谢谢您的帮助
home.html
<h3 *ngIf="debugText">Debug: {{debugText}}</h3>
<span>{{recognizedText}}</span>
<!--<img src="assets/img/demo.png" #demoImg class="start-api" />-->
<img [src]="image" #imageResult />
<div *ngIf="_ocrIsLoaded && !image">
<!--<img src="assets/img/Start-arrow.png" #start class="start-arrow" />-->
</div>
Run Code Online (Sandbox Code Playgroud)
home.ts:
import { Component, ViewChild, ElementRef, NgZone } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Camera } from '@ionic-native/camera';
import { Platform, ActionSheetController, LoadingController } from 'ionic-angular';
import Tesseract from 'tesseract.js';
@Component({
selector: 'page-home', …Run Code Online (Sandbox Code Playgroud) 我像这样导入ChangeDetectorRef:
import { Component, ViewChild, ChangeDetectorRef , ElementRef } from '@angular/core';
Run Code Online (Sandbox Code Playgroud)
并在我的页面的构造函数中初始化更改检测器,如下所示:
constructor(
...
private ref: ChangeDetectorRef
)
Run Code Online (Sandbox Code Playgroud)
但是,当我在回调函数中执行detectChanges()时:
hardResetCallback(car:Car){
this.car=car;
this.ref.detectChanges();
}
Run Code Online (Sandbox Code Playgroud)
它说“无法读取未定义的属性'detectChanges'”。我可能会缺少什么?
编辑:
回调是从模式调用的。模态通过导航参数获取回调-在我称之为的父组件中:
const resetModal : Modal = this.modal.create('CarConfigurationResetPage', { car: this.car, callback: this.hardResetCallback });
resetModal.present();
Run Code Online (Sandbox Code Playgroud)
然后这就是我在模态中得到它的方式:
this.callback=this.navParams.get('callback');
Run Code Online (Sandbox Code Playgroud)
我像这样在AJAX调用的成功方法中从模式调用回调:
this.callback(response);
Run Code Online (Sandbox Code Playgroud) ionic3 ×10
ionic2 ×7
angular ×6
cordova ×3
typescript ×3
node-modules ×2
angularjs ×1
css ×1
css-position ×1
html ×1
ios ×1
native ×1