我不会写app可以通过号码用户输入来调用.
但我使用http://ionicframework.com/docs/v2/native/callnumber/它不起作用.
这是我的代码ts
import { Component } from '@angular/core';
import {CallNumber} from 'ionic-native';
import { Platform, ActionSheetController } from 'ionic-angular';
// import { NavController } from 'ionic-angular';
declare var window;
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(
public platform: Platform,
public actionsheetCtrl: ActionSheetController
) { }
strShowInHtml = "";
callIT(){
// window.location = '12345';
CallNumber.callNumber("12345", true)
.then(() =>{
console.log('Launched dialer!');
this.strShowInHtml="ok";
})
.catch(() => {
console.log('Error launching dialer');
this.strShowInHtml="error";
});
}
}
Run Code Online (Sandbox Code Playgroud)
和我的代码html:
<ion-header>
<ion-navbar>
<ion-title>Action Sheets</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding class="action-sheets-basic-page">
<button md-button (click)="callIT()">callIT</button>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用
<a ion-button href="tel:+0839504890">Call me 1 </a>
Run Code Online (Sandbox Code Playgroud)
但我不想使用它,它将会去查看Call Phone.我想点击按钮,我的应用程序Ionic 2将拨打号码用户输入.
在您的Component类中,请写如下
callIT(mobNumber:string)
{
window.open("tel:" + mobNumber);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5740 次 |
| 最近记录: |