当设备没有摄像头时,我想在Ionic2上发出警报。
当我发布时:离子服务
然后我尝试显示如下消息:
let alert = Alert.create({
title: 'Camera not found',
subTitle: 'It seems your camera is not working on your device',
buttons: ['Ok']
});
this.nav.present(alert);
我有一个javascript错误
Uncaught EXCEPTION: Error during evaluation of "click"
ORIGINAL EXCEPTION: TypeError: rootNav.getActive is not a function
ORIGINAL STACKTRACE:
TypeError: rootNav.getActive is not a function
at Tab.NavController.present (http://localhost:8100/build/js/app.bundle.js:46996:36)
at SmartScan.takePicture (http://localhost:8100/build/js/app.bundle.js:60864:23)
at AbstractChangeDetector.ChangeDetector_SmartScan_0.handleEventInternal (eval at <anonymous> (http://localhost:8100/build/js/app.bundle.js:14578:17), <anonymous>:185:36)
at AbstractChangeDetector.handleEvent (http://localhost:8100/build/js/app.bundle.js:13892:25)
at AppView.dispatchEvent (http://localhost:8100/build/js/app.bundle.js:18772:46)
at AppView.dispatchRenderEvent (http://localhost:8100/build/js/app.bundle.js:18766:22)
at DefaultRenderView.dispatchRenderEvent (http://localhost:8100/build/js/app.bundle.js:33592:39)
at eventDispatcher (http://localhost:8100/build/js/app.bundle.js:33258:22)
at http://localhost:8100/build/js/app.bundle.js:33329:40
答案 0 :(得分:1)
在alert.js中:
Set objFSO = CreateObject("Scripting.FileSystemObject")
If WScript.Arguments.Count < 1 Then
WScript.Quit
End If
objStartFolder = objFSO.GetAbsolutePathName(WScript.Arguments(0))
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
strFileName = objFile.Name
If objFSO.GetExtensionName(strFileName) = "xml" Then
objFSO.CopyFile objFile.Name, "TMP.xml", True
Set objExcel = CreateObject("Excel.Application")
Set xlBook = objExcel.Workbooks.Open("c:/Users/xyz/Desktop/vbs/xyz.xlsm", 0, False)
objExcel.Run "importxml", objStartFolder & "/TMP.xml", objStartFolder & "/out.xml"
xlBook.Close (False)
objExcel.Quit
Set xlBook = Nothing
Set objExcel = Nothing
objFSO.CopyFile "out.xml", objFile.Name & "_out.xml", True
End If
Next
objFSO.DeleteFile "TMP.xml", True
objFSO.DeleteFile "out.xml", True
WScript.Quit
在alert.html中:
import {Page, Alert, NavController} from 'ionic-angular';
@Page({
templateUrl: 'build/pages/alert/alert.html'
})
export class AlertPage {
static get parameters() {
return [[NavController]];
}
constructor(nav) {
this.nav = nav;
}
showAlert() {
let alert = Alert.create({
title: 'New Friend!',
subTitle: 'Your friend, Obi wan Kenobi, just accepted your friend request!',
buttons: ['Ok']
});
this.nav.present(alert);
}
}
答案 1 :(得分:0)
我也在研究ionic2,并且需要实施&#34; PopUp&#34;我现有应用程序中的窗口。 我尝试了很多,因为没有完成我的任务,最后我做了类似的事情 -
弹出up.html
<button block dark (click)="showAlert()">Help Window</button>
弹出up.ts
import { Component } from '@angular/core';
import { Alert, NavController, NavParams} from 'ionic-angular';
@Component({
templateUrl: 'build/pages/pop-up/pop-up.html',
})
export class PopUpPage {
static get parameters() {
return [[NavController]];
}
constructor(private nav: NavController) {
this.nav = nav;
}
showAlert() {
let alert = Alert.create({
title: 'Help Window!',
subTitle: 'Mindfulness is here for you and your soul. We are intended to stablish your connection to All Mighty.',
buttons: ['Cancle']
});
this.nav.present(alert);
}
}
这对我来说很好。
希望它也适合你。
答案 2 :(得分:0)
试试这个:
具有文件夹和文件的这种结构
在:
home.html的
<ion-header>
<ion-navbar>
<ion-title>Ionic 2 Notifications</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<button block dark (click)="showAlert()">Alert</button>
</ion-content>
在:
home.ts
import {Component} from "@angular/core";
import {NavController, AlertController} from 'ionic-angular';
@Component({
templateUrl: 'home.html'
})
export class HomePage {
constructor(public alertCtrl: AlertController) {
}
showAlert() {
let alert = this.alertCtrl.create({
title: 'New Friend!',
subTitle: 'Your friend, Obi wan Kenobi, just accepted your friend request!',
buttons: ['OK']
});
alert.present();
}
}
我从文档站点获得了这些信息: https://ionicframework.com/docs/v2/components/#action-sheets
答案 3 :(得分:-1)
似乎尚未准备好......
调查代码
this.nav.present(alert);
它正在传递并返回:
if (rootNav['_tabs']) {
// TODO: must have until this goes in
// https://github.com/angular/angular/issues/5481
void 0;
return;
}