import {Page,NavController,NavParams,Platform,IonicApp} from 'ionic-angular';
import {ViewChild} from '@angular/core';
@Page({
templateUrl: 'build/pages/tabspage/tabspage.html'
})
@ViewChild('myTabs') tabRef: Tabs
export class TabsPage {
tab1;
tab2;
tab3;
constructor(app:IonicApp, params:NavParams) {
this.tab1 = Page1;
this.tab2 = Page2;
this.tab3 = Page3;
}
onPageDidEnter() {
this.tabRef.select(1);
}
}
Run Code Online (Sandbox Code Playgroud)
我有这个代码。此代码位于打字稿文件中。我收到错误:错误 TS1146:预期的声明。
我在将月份名称翻译成来自另一个国家的另一种语言时遇到了 ionic2问题。在我的视图中,我使用过滤器日期来显示月份的全名。月份的名称以英语显示,我需要它们以巴西的葡萄牙语显示。
当我使用ionic1 时,我只是访问了文件“ionic.bundle.min.js”,然后我更改了英文月份的名称。已经换了ionic2我还是不知道我应该怎么做才能改个语言。
谁能帮我这个?
我有问题,我尝试将默认日期设置为今天结束禁用日期。
但是当我将默认日期设置为今天时,我必须将日期转换为字符串。所以我无法计算这个。
有人帮我设置默认日期是今天和计算器日期。感谢您阅读我的主题!
这是我的代码:
this.startDate = new Date().toISOString();
this.minDate = new Date().toISOString();
<ion-datetime
displayFormat="MMM DD, YYYY HH:mm"
[min]="minDate"
[(ngModel)]="startDate"
>
</ion-datetime>
Run Code Online (Sandbox Code Playgroud) 我已经创建了一个简单的注射器,我正在使用它进行模拟测试,直到我想要实现我的提供者来检索用户数据.它看起来像这样:
import { Injectable } from '@angular/core';
@Injectable()
export class Identity {
public userInfo: {id: 1};
}
Run Code Online (Sandbox Code Playgroud)
我在我的aa组件中请求它是这样的:
export class TabsPage {
constructor(public identity: Identity) {
console.log(this.identity.userInfo);
}
}
Run Code Online (Sandbox Code Playgroud)
Identity是Injected正常但userInfo未定义,这里发生了什么?如何通过我的提供商传递数据?
我有图片网址,例如:https : //lh3.googleusercontent.com/-lLC-FsscD40/AAAAAAAAAAI/AAAAAAAAAAA/AMp5VUoSrLythVKtt5Skm9zIUg4uyxnNCw/s48-c-mo/photo.jpg
需要将url转换为base 64图像,我的代码不起作用,请帮助:
convertToDataURLviaCanvas(url){
return new Promise( (resolve, reject) => {
let img = new Image();
img.crossOrigin = 'Anonymous';
img.src = url;
var canvas = <HTMLCanvasElement>document.createElement("canvas");
canvas.width =img.width;
canvas.height =img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL("image/jpeg");
resolve(dataURL);
});
}
Run Code Online (Sandbox Code Playgroud) 美好的一天,我一直试图按群组标题显示数组,我从网络服务获取我的数组,我想按群组标题显示项目
例
第1组第1项第2项第3项
第2组第1项第2项第3项
这是我的阵列
[
{
"id": "1",
"title": "Item 1",
"groups": [
{
"id": "2",
"title": "Communication"
}
]
},
{
"id": "2",
"title": "Item 2",
"groups": [
{
"id": "2",
"title": "Communication"
}
]
},
{
"id": "3",
"title": "Item 1",
"groups": [
{
"id": "1",
"title": "Creativie Art"
}
]
},
{
"id": "4",
"title": "Item 3",
"groups": [
{
"id": "2",
"title": "Communication"
}
]
},
{
"id": "5",
"title": "Item 2",
"groups": [
{ …Run Code Online (Sandbox Code Playgroud) 我找到了一个为codova制作的插件:
https : //github.com/dff-solutions/dff-cordova-plugin-honeywell
该文档描述了如何直接使用对象Honeywell,但没有介绍如何导入到app.module中。并做出适当的调整。我还没有发现关于离子本地开发或清晰的文档科尔多瓦插件移植到离子2.
请任何指导线如何得到任何科尔多瓦插件融入现代离子2。
更新:在我的情况下,有一些解决方法,因为我有一个由插件创建的全局变量,所以我在@Component装饰器之前声明该变量。但这招破坏了依赖注入系统。
import { Component, NgZone } from '@angular/core';
import { NavController } from 'ionic-angular';
declare var Honeywell;//declare the global created by the plugin
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
barcode: string;
constructor(public navCtrl: NavController, public zone: NgZone) {
Honeywell
.onBarcodeEvent( ... );
}
}
Run Code Online (Sandbox Code Playgroud) ionic info
Run Code Online (Sandbox Code Playgroud)
cli软件包:(/ usr / local / lib / node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
Run Code Online (Sandbox Code Playgroud)
全局软件包:
cordova (Cordova CLI) : 8.0.0
Run Code Online (Sandbox Code Playgroud)
本地套餐:
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 6.3.0
Ionic Framework : ionic-angular 3.9.2
Run Code Online (Sandbox Code Playgroud)
系统:
Node : v8.11.0
npm : 5.6.0
OS : macOS High Sierra
Run Code Online (Sandbox Code Playgroud)
环境变量:
ANDROID_HOME : not set
Run Code Online (Sandbox Code Playgroud)
其他:
backend : pro
Run Code Online (Sandbox Code Playgroud)
我的提供者
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
@Injectable()
export class GlobalTokenProvider {
constructor(public storage: Storage) …Run Code Online (Sandbox Code Playgroud) 当切换按钮"打开"时,请参阅下面的函数buttonOn(),

我想在buttonOff()"关闭"时切换它,如下所示
html的
<ion-toggle (ionChange)="buttonOn()"></ion-toggle>
Run Code Online (Sandbox Code Playgroud)
.TS
buttonOn() {
// this function is called;
}
buttonOff() {
// how to call this function when toggle button gets off?
}
Run Code Online (Sandbox Code Playgroud) 将我的节点模块更新到最新版本,包括离子核心等.我收到此错误,我似乎无法找到任何相关信息?有些帮助吗?有没有更改为本地通知插件或任何其他可能让我这个错误?
[15:34:51] transpile started …
[15:35:10] typescript: D:/ionic/myApp1/src/pages/home/home.ts, line: 13
Expected 1 arguments, but got 2.
L12: this.platform.ready().then(() => {
L13: this.localNoti.on(‘click’, (noti, state) => {
L14: alert(state);
Error: Failed to transpile program
at new BuildError (D:\ionic\myApp1\node_modules@ionic\app-scripts\dist\util
\errors.js:16:28)
at D:\ionic\myApp1\node_modules@ionic\app-scripts\dist\transpile.js:159:20
at new Promise ()
at transpileWorker (D:\ionic\myApp1\node_modules@ionic\app-scripts\dist\tra
nspile.js:107:12)
at Object.transpile (D:\ionic\myApp1\node_modules@ionic\app-scripts\dist\tr
anspile.js:64:12)
at D:\ionic\myApp1\node_modules@ionic\app-scripts\dist\build.js:109:82
Run Code Online (Sandbox Code Playgroud) ionic2 ×10
angular ×5
ionic3 ×3
typescript ×3
angular-pipe ×1
angularjs ×1
cordova ×1
ion-toggle ×1
ionic-view ×1
javascript ×1
ngfor ×1