我使用generate命令在ionic 3中生成了一个新页面.当我尝试将其添加到app模块时,它会抛出以下错误,
Uncaught Error: Unexpected value 'NewTodo' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation.
Run Code Online (Sandbox Code Playgroud)
以前在使用离子2.x时我从未手动添加注释.知道我怎么解决它?
UPDATE
new-todo.ts文件
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {Data} from '../../providers/data';
import { ToastController } from 'ionic-angular';
@Component({
selector: 'page-new-todo',
templateUrl: 'new-todo.html',
})
class Todo {
public title: string;
public completed: boolean;
constructor() {
this.title = '';
this.completed = false;
}
}
export class NewTodo {
todo: Todo;
constructor(public navCtrl: NavController, public …Run Code Online (Sandbox Code Playgroud) 我曾尝试使用Firebase本机插件发送推送通知.但它无法正常工作(没有收到真实设备的消息).你能告诉我怎么做吗?
app.component.ts
constructor(platform: Platform, private firebase: Firebase) {
platform.ready().then(() => {
this.firebase.getToken()
.then(token => console.log(`The token is ${token}`)) // save the token server-side and use it to push notifications to this device
.catch(error => console.error('Error getting token', error));
this.firebase.onNotificationOpen()
.subscribe(res => {
if (res.tap) {
// background mode
console.log("background");
console.log(res);
alert(res);
} else if (!res.tap) {
// foreground mode
console.log("foreground");
console.log(res);
alert(res);
}
});
});
}
Run Code Online (Sandbox Code Playgroud)
完成上述实现后,我尝试使用User Segmentfirebase compose消息控制台发送推送通知.
我试图在离子角3.3.0中创建Login/SignUp.我收到错误找不到模块'../providers/auth-service/auth-service'.在login.ts文件中.请帮忙!
AUTH-service.ts
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map';
/*
Generated class for the AuthServiceProvider provider.
See https://angular.io/docs/ts/latest/guide/dependency-injection.html
for more info on providers and Angular 2 DI.
*/
export class User {
name: string;
email: string;
constructor(name: string, email: string) {
this.name = name;
this.email = email;
}
}
@Injectable()
export class AuthServiceProvider {
currentUser: User;
public login(credentials) {
if (credentials.email === null || credentials.password === null) {
return …Run Code Online (Sandbox Code Playgroud) Ionic 2文档使它看起来像箭头自动随附.然而,对我来说这不是那样的.
https://ionicframework.com/docs/components/#lists
<ion-list>
<ion-item>
<p>Terms Of Use</p>
</ion-item>
<ion-item>
<p>Privacy Policy</p>
</ion-item>
</ion-list>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Ionic2/typescript进行电话号码身份验证,并初始化recaptcha验证程序,如下所示:
.ts文件
import firebase from 'firebase';
@IonicPage()
@Component({
selector: 'page-login',
templateUrl: 'login.html',
})
export class LoginPage {
public recaptchaVerifier:firebase.auth.RecaptchaVerifier;
constructor(afAuth: AngularFireAuth, public authData: AuthProvider, public alertController: AlertController, formBuilder: FormBuilder, public navCtrl: NavController, public navParams: NavParams) {
this.loginForm = formBuilder.group({
phone: ['', Validators.compose([Validators.required,
Validator.isValidPhone])]
});
try {
this.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
}catch(e){
console.log("There was a problem in initializing the recapctha verifier: " + e);
}
this.authData.recaptchaVerifier = this.recaptchaVerifier;
}
}
Run Code Online (Sandbox Code Playgroud)
.html文件
<ion-content padding>
<div id="recaptcha-container"></div>
<form [formGroup]="loginForm" (submit)="loginUser()" novalidate> …Run Code Online (Sandbox Code Playgroud) 我正在开发Ionic 3应用程序。现在,我NavController用于路由和切换页面。
例如: this.navCtrl.push(DetailsPage);
但是我现在需要使用Angular路由。
我为Ionic 2 找到了类似的问题,但是在Ionic 3中也可以使用吗?
有人可以详细说明吗?
我正在研究IONIC 3,现在正在开发一个使用usig Google Maps API的应用程序。问题是我正在尝试执行我的应用程序,但是当它启动时,会出现以下消息:
inicio.html
Error: Uncaught (in promise): TypeError: Cannot read property
'nativeElement' of undefined
TypeError: Cannot read property 'nativeElement' of undefined
Run Code Online (Sandbox Code Playgroud)
这是产生问题的代码:
inicio.ts(仅是代码的一部分)
loadMap(){
this.geolocation.getCurrentPosition().then((position)=>{
let latLng = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
this.map = new google.maps.Map(this.mapElement.nativeElement,
mapOptions);
}, (err) => {
console.log(err);
});
}
Run Code Online (Sandbox Code Playgroud)
inicio.ts(完整代码)
import { Component,ViewChild, ElementRef } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Geolocation } from '@ionic-native/geolocation';
import …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用离子3中的jquery在div中加载外部网站.
TS:
export class HomePage
{
constructor(public navCtrl: NavController) {
$('#loadExternalURL').load('http://www.google.com');
}
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<ion-content>
<div id="loadExternalURL"></div>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
我正在为离子应用程序提供空白屏幕.有什么我想念的吗?有什么建议吗?
我是Ionic应用程序开发的新手,我一直在关注相同的教程。
我一直在尝试使用,IonicStorageModule但即使在chrome浏览器移动视图模式下运行应用程序时没有错误,也不会生成本地存储密钥。
在我的app.module.ts,我有
import { IonicStorageModule } from '@ionic/storage';
Run Code Online (Sandbox Code Playgroud)
然后我在imports数组中有以下导入,
imports: [
BrowserModule,
HttpModule,
IonicModule.forRoot(MyApp),
IonicStorageModule.forRoot()
],
Run Code Online (Sandbox Code Playgroud)
现在,我创建了一个名为的服务user-settings.service.ts,
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
@Injectable()
export class UserSettings {
constructor(private storage:Storage){}
favoriteTeam(team,tournamentId, tournamentName) {
debugger;
let item = { team: team,tournamentId : tournamentId, tournamentName : tournamentName};
this.storage.set('teamId' , item);
}
unFavoriteTeam(team) {
this.storage.remove(team.id);
}
isFavoriteTeam(team) {
return this.storage.get(team.id).then(value => value ? true : false);
}
} …Run Code Online (Sandbox Code Playgroud) Href ="tel"不能用于离子3,这是我的代码
<ion-item color="none" href="tel:(51) 9 9222 - 7607">
<ion-icon name="call" item-left></ion-icon>
Contato: {{ property.contato1 }}
</ion-item>
Run Code Online (Sandbox Code Playgroud)
ionic3 ×10
angular ×6
ionic2 ×6
javascript ×3
typescript ×3
firebase ×2
angularfire ×1
css ×1
geolocation ×1
google-maps ×1
html ×1
jquery ×1