标签: ionic3

如何更改离子按钮文本颜色

这可能是一个愚蠢的问题,但我对 ionic 和 css 不太熟悉,所以有人能告诉我如何更改 ionic 按钮的文本颜色吗?

<div class="bottom-button" margin text-center>
     <button ion-button color="energized">
       Register
     </button>
</div>
Run Code Online (Sandbox Code Playgroud)

这里,按钮颜色为黄色,文本颜色为黑色。我想将文本颜色更改为白色。

html css ionic3

5
推荐指数
1
解决办法
1万
查看次数

需要 Angular 自定义组件

有没有办法可以required在我的自定义组件上使用该属性?我的组件如下所示:

import { Component, Input, forwardRef } from '@angular/core';
import { Platform } from 'ionic-angular';
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';

export const CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR: any = {
  provide: NG_VALUE_ACCESSOR,
  useExisting: forwardRef(() => DatePickerComponent),
  multi: true
};

@Component({
  selector: 'date-picker',
  templateUrl: 'date-picker.html',
  providers: [CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR]
})
export class DatePickerComponent implements ControlValueAccessor {
  @Input("label") label: string;
  @Input("pickerFormat") pickerFormat: string;
  @Input("displayFormat") displayFormat: string;
  @Input("max") max: string;
  @Input("min") min: string;
  @Input("cancelText") cancel: string;
  @Input("doneText") done: string;
  @Input("valid") valid: boolean;
  @Input("disabled") disabled: boolean; …
Run Code Online (Sandbox Code Playgroud)

custom-component required ionic-framework ionic3 angular

5
推荐指数
1
解决办法
1165
查看次数

如何在 iOS (Ionic 2/3) 中下载文件?

我正在尝试下载文件并将该文件保存在 iOS 中。我正在使用ionic-native-file插件来实现这一点。该文件已下载,但我在设备中找不到该文件。

filewrite = (): void => {
    let transfer = this.fileTransfer.create();
    let path = "";
    let dir_name = 'Download';
    let file_name = "Sample.pdf";

    if (this.platform.is('ios')) {
      this.platform.ready().then(() => {
          path = this.file.documentsDirectory;

          this.file.writeFile(path,file_name,this.pdfSrc).then((entry) => {
            this.showAlert("download completed");
          }, (error) => {
            this.showAlert("Download Failed.");
          }).catch(err=>{
            this.showAlert("Download Failed catch.");
            this.showAlert(err.message);

          });
        }
      )
    }
  };
Run Code Online (Sandbox Code Playgroud)

下载完成提示显示,下载路径为:

file:///var/mobile/Containers/Data/Application/6DE22F30-5806-4393-830A-14C8A1F320BE/Library/Cloud/Sample.pdf

但是我在设备中找不到那个位置。然后,我谷歌并看到这里。

cordova.file.documentsDirectory - 应用程序私有的文件,但对其他应用程序有意义(例如 Office 文件)。请注意,对于 OSX,这是用户的 ~/Documents 目录。(iOS、OSX)

所以,我实际上看不到该文件,因为它是应用程序私有的。然后我在同一个链接中看到:

在此处输入图片说明

所以,我在我的 config.xml 中尝试了两者的偏好,但没有发生任何事情。

有什么方法可以下载文件 iOS 或 Dropbox 或其他任何地方?

file ios ionic-framework ionic3

5
推荐指数
1
解决办法
2892
查看次数

如何在我的 Angular 4 项目中导入 wavesurfer.js?

我在 Ionic 3 应用程序中使用Video.js来处理视频和音频,一切正常。但是现在,我想将Video.js Wavesufer 插件用于音频。

我通过 npm 安装了插件:

npm install videojs-wavesurfer --save (plugin)
npm install wavesurfer.js --save (dependency)
Run Code Online (Sandbox Code Playgroud)

并将它们导入到我的 component.ts 中:

import WaveSurfer from 'wavesurfer.js';
import VideojsWavesurfer from 'videojs-wavesurfer';
Run Code Online (Sandbox Code Playgroud)

我调用videojs函数来初始化播放器:

ngAfterViewInit() {
    if (this.audio) {
        this.audio = this.audio.nativeElement;

        let audioJS = videojs(this.audio,
          {
            fluid: true,
            plugins: {
              wavesurfer: {
                src: this.audioSource,
                msDisplayMax: 10,
                debug: true,
                waveColor: 'grey',
                progressColor: 'black',
                cursorColor: 'black',
                hideScrollbar: true
              }
            }
          }, () => { }
        );
      }
  } …
Run Code Online (Sandbox Code Playgroud)

video.js typescript wavesurfer.js ionic3 angular

5
推荐指数
1
解决办法
2876
查看次数

特定时间的离子后台任务?

无论如何我可以在特定时间在 Ionic 3 移动应用程序中启动后台任务吗?

提前致谢。

typescript hybrid-mobile-app ionic3

5
推荐指数
1
解决办法
2701
查看次数

Ionic 3 文件插件错误安全错误。

我正在尝试读取以上传从存储读取的文件到 firebase。将文件作为数组缓冲区读取时出现此错误

{"code": 2, message:"SECURITY_ERR"}
Run Code Online (Sandbox Code Playgroud)

这是代码

 this.file.readAsArrayBuffer(dirPath,url.name).then((buffer)=>{
        // this.upload(buffer,url.name);

        let blob = new Blob([buffer],{type:'image/jpeg'})

        alert(blob);

        firebase.storage().ref('files/'+url.name).put(blob).then((d)=>{
          alert(JSON.stringify(d));
        }).catch(e=>{
          alert(e);
        })
    }).catch(e=>{
      alert(JSON.stringify(e));
    })
Run Code Online (Sandbox Code Playgroud)

我还添加了所有这些权限 READ_EXTERNAL_STORAGE WRITE_EXTERNAL_STORAGE

javascript file typescript ionic-framework ionic3

5
推荐指数
0
解决办法
266
查看次数

无法显示来自 FILE URI、Ionic 框架的图像

我正在尝试显示从相机拍摄的图像并将其显示在视图中。我在许多网站上搜索过这个答案,但没有任何效果。我尝试过 DomSanitizer、Base64 甚至 photo-library,但没有显示从它们返回的图像。

我的 home.ts 文件是

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Camera, CameraOptions } from '@ionic-native/camera';
import { DomSanitizer } from '@angular/platform-browser';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  myPhoto:any;
  image;
  constructor(public navCtrl: NavController, private camera: Camera, public DomSanitizer: DomSanitizer) {

  }

  takePhoto(){
    const options: CameraOptions = {
      quality: 100,
      targetHeight: 320,
      targetWidth: 320,
      destinationType: this.camera.DestinationType.FILE_URI,
      sourceType: this.camera.PictureSourceType.CAMERA,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE
    }

    this.camera.getPicture(options).then((imageData) => {
     // …
Run Code Online (Sandbox Code Playgroud)

ionic-framework ionic2 ionic-native ionic3

5
推荐指数
1
解决办法
4715
查看次数

没有带有cordova &gt;= 7的AndroidManifest.xml文件

我有一个 ionic 项目,我需要使用Batch。为了在最新版本 (2.0.0) 中使用 Batch,我应该将我cordova-android的>=7.0.0.

但问题是,如果我将该依赖项更新为所需版本,所有其他插件都会失败,因为它们尚不支持该cordova-android版本。

基本上,它说AndroidManifest.xml找不到文件:

(node:8420) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open '/<mypath>/platforms/android/AndroidManifest.xml'
Run Code Online (Sandbox Code Playgroud)

如果我执行以下步骤:

  1. 删除 android 平台 ( cordova platform remove android)。
  2. 删除 node_modules 和插件 ( rm -rf /node_modules /plugins)。
  3. 删除packaje.json和 中的插件条目config.xml。
  4. 再次添加android平台( cordova platform add android)。

安卓平台已创建。但是,如果我尝试添加批处理插件,我会遇到相同的错误(当他们说cordova-android >= 7仅支持时):

ionic cordova plugin add com.batch.cordova
> cordova plugin add …
Run Code Online (Sandbox Code Playgroud)

android cordova ionic-framework cordova-plugins ionic3

5
推荐指数
1
解决办法
2380
查看次数

为什么 observable.subscribe 仅适用于构造函数

在使用 Ionic 3 应用程序时,我遇到了一个问题,即当您observable从 service in订阅ngOnInit并将局部变量更新到其中时,它不会更新视图。

例如 HTML 模板 <p>{{myVariable}}</p>

constructor(myService: MyService) {
}
ngOnInit() {
  this.myService.myObservable.subscribe((data) => {
    this.myVariable = data;
  });
}
Run Code Online (Sandbox Code Playgroud)

但是当你从构造函数做同样的事情时,它就起作用了。

contructor(myService: MyService) {
  this.myService.myObservable.subscribe((data) => {
    this.myVariable = data;
  });
}
Run Code Online (Sandbox Code Playgroud)

它是一个 Ionic 3 应用程序。它包含不同的离子标签。问题是当您订阅时视图不会自动更新ngOnInit。您可以在选项卡之间切换以使其工作。但是当您订阅 constructor 它时,它无需切换标签即可工作。

知道为什么会这样。任何提示将不胜感激。谢谢。

observable ionic-framework ionic3 angular

5
推荐指数
1
解决办法
4695
查看次数

聚焦离子输入时有没有办法隐藏键盘?

我想要一个离子输入,它会被聚焦并且键盘不应该出现。有什么办法或者有可能吗?谢谢!

setfocus ionic-framework ionic-keyboard ionic3

5
推荐指数
1
解决办法
3034
查看次数