I have install 'angular2-signaturepad' in my ionic project, and I created a test app and that's working fine, But when I try to integrate with my existing project shows me 'signature-pad' is not a known element' and '
<ion-content padding>
<signature-pad [ERROR ->][options]="signaturePadOptions"
(onBeginEvent)="drawStart()" (onEndEvent)="drawComplete()"></signatur"):
ng:///SignPageModule/SignPage.html#10:16
'signature-pad' is not a known element:
1. If 'signature-pad' is an Angular component, then verify that it is part of this module.
2. If 'signature-pad' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '#NgModule.schemas' of this component to suppress this message. ("
<ion-content padding>
[ERROR ->]<signature-pad [options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplet"): ng:///SignPageModule/SignPage.html#10:1
Error: Template parse errors:
Can't bind to 'options' since it isn't a known property of 'signature-pad'.
1. If 'signature-pad' is an Angular component and it has 'options' input, then verify that it is part of this module.
2. If 'signature-pad' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '#NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '#NgModule.schemas' of this component
This is the error I m facing. I was added 'CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA' in my app.module.ts file.
This is my sign.html code:
<ion-header>
<ion-navbar>
<ion-title>sign</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-row [ngClass]="{'drawing-active': isDrawing}">
<ion-col></ion-col>
<ion-col style="border: 1px solid #5d6691;">
<signature-pad [options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplete()" style="width: 50px; height: 580px; color: red;"> </signature-pad>
</ion-col>
<ion-col></ion-col>
</ion-row>
<ion-row>
<ion-col>
<button ion-button style="color: #fff; background: #e59c9c;" (click)="clearPad()">Clear</button>
</ion-col>
<ion-col>
<button ion-button style="color: #fff; background: #4355a5;" (click)="savePad()">Save</button>
</ion-col>
<ion-col>
<button ion-button style="color: #fff; background: #e59c9c;" (click)="delPad()">delete</button>
</ion-col>
</ion-row>
<ion-row text-center>
<ion-col width-120>
<img [src]="signature" [hidden]= "signature == '' || signature == undefined " style="height: 200px;" />
</ion-col>
</ion-row>
This is my sign.ts code:
import { Component, ViewChild } from '#angular/core';
import { IonicPage, NavController, NavParams, ToastController } from 'ionic-angular';
import { SignaturePad } from 'angular2-signaturepad/signature-pad';
import { Storage } from '#ionic/storage';
#IonicPage()
#Component({
selector: 'page-sign',
templateUrl: 'sign.html',
})
export class SignPage {
public signature = '';
isDrawing = false;
#ViewChild(SignaturePad) signaturePad: SignaturePad;
private signaturePadOptions: Object = {
'minWidth': 1,
'canvasWidth': 320,
'canvasHeight': 200,
'backgroundColor': '#f6fbff',
'penColor': '#06219b'
};
constructor(public navCtrl: NavController,
public navParams: NavParams,
public storage: Storage,
public toastCtrl: ToastController ) {
}
ionViewDidLoad() {
this.signaturePad.clear()
this.storage.get('savedSignature').then((data) => {
this.signature = data;
});
}
drawComplete() {
this.isDrawing = false;
}
drawStart() {
this.isDrawing = true;
}
savePad() {
this.signature = this.signaturePad.toDataURL();
this.storage.set('savedSignature', this.signature);
this.signaturePad.clear();
let toast = this.toastCtrl.create({
message: 'New Signature saved.',
cssClass: 'homeToast',
duration: 3000,
position: 'top'
});
toast.present();
}
clearPad() {
this.signaturePad.clear();
}
delPad(){
this.storage.clear();
this.signature = '';
}
}
This is my app.module.ts code:
import { BrowserModule } from '#angular/platform-browser';
import { ErrorHandler, NgModule, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '#angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '#ionic-native/splash-screen';
import { StatusBar } from '#ionic-native/status-bar';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { SignaturePadModule } from 'angular2-signaturepad';
import { IonicStorageModule } from '#ionic/storage';
#NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp,{
backButtonText: '',
autoFocusAssist: true }),
SignaturePadModule,
IonicStorageModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
],
schemas: [ CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA ]
})
export class AppModule {}
I expected signature-pad to be working fine
Make sure to also import the module in sign.module.ts
import { SignaturePadModule } from 'angular2-signaturepad';
#NgModule({
imports: [
...
SignaturePadModule
],
declarations: [SignPage]
})
export class SignPageModule {}
Related
I have created a new app using Ionic v4 and tried adding slides to my app but I get an error stating
Can't bind to 'options' since it isn't a known property of 'ion-slides'
The html is
<ion-content padding>
<ion-slides [options]="slideOpts">
<ion-slide>
<h1>Slide 1</h1>
</ion-slide>
<ion-slide>
<h1>Slide 2</h1>
</ion-slide>
<ion-slide>
<h1>Slide 3</h1>
</ion-slide>
</ion-slides>
</ion-content>
My Ts is
import { Component,ViewChild } from '#angular/core';
import { NavController } from 'ionic-angular';
#Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
slideOpts = {
initialSlide: 1,
speed: 400
};
constructor(public navCtrl: NavController) {
}
}
However the same worked for me in Ionic v3. Could anyone please help me out?
Try this.. its working fine ionic 4.0.0
import { IonSlides } from '#ionic/angular';
#Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
#ViewChild(IonSlides) slides: IonSlides;
slideOpts = {
initialSlide: 1,
speed: 400
};
constructor(public navCtrl: NavController) {
}
ngOnInit() { this.slideOpts = {
initialSlide: 1,
speed: 400
};
}
}
Just laying my point here, especially for new people like me, so i'll try to go slow.
Assuming SlideComponent is an independant component like Directory
You already have a components.module.ts to export all components created in the components folder.
Here's how components.module.ts will look like:
import { NgModule } from '#angular/core';
import { CommonModule } from '#angular/common';
import { SlidesComponent } from './slides/slides.component';
import { IonicModule } from '#ionic/angular'; //import
#NgModule({
declarations: [SlidesComponent,],
exports:[SlidesComponent, /*feel free to add any additional component*/],
imports: [
CommonModule,
IonicModule //add
]
})
export class ComponentsModule { }
PS: this works on Ionic V 6.5
This is my first application using ionic4 and there is something weird happening. When I tap on any link, there is delay and the entire background blinks before it loads the page. Here is a video showing this weird behave: https://youtu.be/NqoOMQYyr4k
For reference, here is the code for the pages:
On the global.scss i have this property to setup the background
ion-content {
--background: #000 url('./assets/images/main-bg.png') no-repeat center center / cover;
}
news.page.ts
import { News } from './news.model';
import { Component, OnInit } from '#angular/core';
import { NewsService } from '../services/news.service';
import { Router } from '#angular/router';
import { NavController } from '#ionic/angular';
#Component({
selector: 'app-news',
templateUrl: './news.page.html',
styleUrls: ['./news.page.scss'],
})
export class NewsPage implements OnInit {
news: any;
constructor(private newsService: NewsService, private router: Router, private navController: NavController) { }
ngOnInit() {
this.news = this.newsService.getAllEvents();
}
go(id: string) {
this.navController.navigateForward('news/' + id);
}
}
news.page.html
<ion-header>
<ion-toolbar color="grey">
<ion-buttons slot="start">
<ion-menu-button></ion-menu-button>
</ion-buttons>
<ion-title style="color: #524A4A!important">News</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-grid padding class="margin-logo-header">
<ion-row>
<div>
<h2>Noticias HD Friends</h2>
</div>
</ion-row>
</ion-grid>
<ion-card color="grey" *ngFor="let news of news | async">
<ion-nav-pop (click)="go(news.id)" >
<ion-img src="{{news.picture}}"></ion-img>
<ion-card-header>
<ion-card-title>{{ news.title }}</ion-card-title>
</ion-card-header>
<ion-card-content>
<p>{{ news.subtitle }}</p>
</ion-card-content>
</ion-nav-pop>
</ion-card>
</ion-content>
news.service.ts
import { Injectable } from '#angular/core';
import { AngularFireDatabase, AngularFireList } from '#angular/fire/database';
import { News } from '../news/news.model';
#Injectable({
providedIn: 'root'
})
export class NewsService {
NODE = 'news/';
news: AngularFireList<News[]>;
constructor(private db: AngularFireDatabase) { }
getAllEvents() {
const localNews = this.db.list(this.NODE);
return localNews.valueChanges();
}
getNews(id: string) {
return this.db.object(this.NODE + id);
}
}
Is this a bug because it's a beta or is this something I messed up?
Thanks guys
UPDATE 1
This seems to be a bug on ionic framework. As soon as I get something I'll post here for future reference.
Using Ionic4 for the first time and struggling with ngSubmit not triggering the respective method in the login page. Although its always successfully hitting the LoginPage constructor and AuthService constructor. All the respective modules have been imported and there are no console errors too. What am i doing wrong ?
login.page.html:
<ion-header>
<ion-toolbar>
<ion-title>
Login
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<form (ngSubmit)="login()" [formGroup]="loginForm">
<ion-grid>
<ion-row>
<ion-col>
<ion-item>
<ion-input type="text" placeholder="Email" formControlName="email" style="width:50%;"></ion-input>
</ion-item>
</ion-col>
</ion-row>
<ion-row>
<ion-col col-3>
<ion-item>
<ion-input type="password" placeholder="Password" formControlName="password" style="width:50%;"></ion-input>
</ion-item>
</ion-col>
</ion-row>
</ion-grid>
<div padding-horizontal>
<div class="form-error">{{loginError}}</div>
</div>
<ion-grid>
<ion-row>
<ion-col>
<ion-button type="submit" [disabled]="!loginForm.valid" color="primary">Log in</ion-button>
Forgot password?
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-button icon-left block clear (click)="loginWithGoogle()" color="secondary">
<ion-icon name="logo-google"></ion-icon>
Log in with Google
</ion-button>
<ion-button icon-left block clear (click)="signup()" color="primary">
<ion-icon name="person-add"></ion-icon>
Sign up
</ion-button>
</ion-col>
</ion-row>
</ion-grid>
</form>
</ion-content>
login.page.ts:
import { Component, OnInit } from '#angular/core';
import { AuthService } from '../common/services/auth.service';
import { FormGroup, FormBuilder, Validators } from '#angular/forms';
import { Router } from '#angular/router';
#Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {
loginForm: FormGroup;
loginError: string;
constructor(private auth:AuthService,
private router:Router,
private fb: FormBuilder)
{
this.loginForm = this.fb.group({
email: ['', Validators.compose([Validators.required, Validators.email])],
password: ['', Validators.compose([Validators.required, Validators.minLength(6)])]
});
}
ngOnInit() {}
login() {
alert('login');
let data = this.loginForm.value;
if (!data.email) {
return;
}
let credentials = {
email: data.email,
password: data.password
};
this.auth.signInWithEmail(credentials)
.then(
() => this.router.navigate(['/home']),
error => this.loginError = error.message
);
}
}
login.module.ts:
import { NgModule } from '#angular/core';
import { CommonModule } from '#angular/common';
import { FormsModule,ReactiveFormsModule } from '#angular/forms';
import { Routes, RouterModule } from '#angular/router';
import { IonicModule } from '#ionic/angular';
import { LoginPage } from './login.page';
const routes: Routes = [
{
path: '',
component: LoginPage
}
];
#NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
IonicModule,
RouterModule.forChild(routes),
],
entryComponents: [LoginPage],
declarations: [LoginPage]
})
export class LoginPageModule {}
auth.service.ts:
import { Injectable } from '#angular/core';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import AuthProvider = firebase.auth.AuthProvider;
#Injectable({
providedIn: 'root'
})
export class AuthService {
private user: firebase.User;
constructor(public afAuth: AngularFireAuth) {
afAuth.authState.subscribe(user => {
this.user = user;
});
}
signInWithEmail(credentials) {
console.log('Sign in with email');
return this.afAuth.auth.signInWithEmailAndPassword(credentials.email,
credentials.password);
}
}
ngSubmit is reloading the complete page and hence its hitting only login constructor but not the respective method. Removed (ngSubmit) on <form>, type="submit" on <ion-button>, added (click)="login()" event to <ion-button>. It started working.
At first I have added the ReactiveFormModule in app.module.ts
import { BrowserModule } from '#angular/platform-browser';
import { NgModule } from '#angular/core';
import { RouterModule, Routes} from '#angular/router';
import { ReactiveFormsModule } from '#angular/forms';
import { AppComponent } from './app.component';
import { NewproducComponent } from './comp/newproduc/newproduc.component';
import { ProductsComponent } from './comp/products/products.component';
import { SidebarComponent } from './comp/sidebar/sidebar.component';
import { MenubarComponent } from './comp/menubar/menubar.component';
const appRoutes: Routes = [
{ path : '' , component : ProductsComponent},
{ path : 'newproduct' , component : NewproducComponent}
];
#NgModule({
declarations: [
AppComponent,
NewproducComponent,
ProductsComponent,
SidebarComponent,
MenubarComponent
],
imports: [
BrowserModule,
ReactiveFormsModule,
RouterModule.forRoot(appRoutes)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}
the app.component.html contanis
<app-menubar></app-menubar>
<app-sidebar></app-sidebar>
<div class="container">
<router-outlet></router-outlet>
</div>
the newproduc.component.html contains
<div id="main-body">
<div class="main-body-header">
<span>New Product</span>
<button type="button">Close</button>
<button type="button">Save</button>
</div>
<div class="main-body-component">
<div class="container">
<form>
</form>
</div>
</div>
</div>
when adding this form tag i am getting the following error
Error in browser console
Whenever, I remove the form tag the error removes. I am not sure where i made the error. Please help me in solving the issue. I have stacked for last 2 days.
Do:
<form [formGroup]="form">
Because you are importing ReactiveFormsModule, the <form> tag must have a formGroup.
I am new to IONIC framework.Need to develop mobile application using IONIC 3 and firebase used to store data and for authentication. Installed all required modules through npm.
Followed below steps to create IONIC 3 app
1) ionic start TestDemo tabs
2) ionic generate page signup
3) npm install firebase angularfire2 --save
4) imported to app.module.ts
import { StatusBar } from '#ionic-native/status-bar';
import { SplashScreen } from '#ionic-native/splash-screen';
import { AngularFireModule } from 'angularfire2';
import { AngularFireAuthModule } from 'angularfire2/auth';
import { environment } from '../environments/environment';
#NgModule({
declarations: [
WelcomePage,
LoginPage,
SignupPage,
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
AngularFireModule.initializeApp(environment.firebase),
AngularFireAuthModule
]
5) signup.ts
import { Component, ViewChild } from '#angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { AngularFireAuth } from 'angularfire2/auth';
#IonicPage()
#Component({
selector: 'page-signup',
templateUrl: 'signup.html',
})
export class SignupPage {
#ViewChild("email") email;
#ViewChild("mobileno") mobileno;
#ViewChild("username") username;
#ViewChild("password") password;
constructor(public navCtrl: NavController, public navParams: NavParams,private fire: AngularFireAuth ) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad SignupPage');
}
async signup(){
try{
const result = await this.fire.auth.createUserWithEmailAndPassword(this.username.value,this.password.value);
console.log(result);
}
catch(err){
console.log("Error");
}
}
}
6) signup.html
<ion-header>
<ion-navbar>
<ion-title>signup</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-item>
<ion-label floating>Email</ion-label>
<ion-input type="text" #email></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Mobile No</ion-label>
<ion-input type="text" #mobileno></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input type="text" #username></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Password</ion-label>
<ion-input type="password" #password></ion-input>
</ion-item>
<button ion-button round (click)="signup()">Sign Up</button>
</ion-list>
</ion-content>
7) ionic serve
then it giving below error
Error: Cannot find module "#firebase/auth"
at webpackMissingModule (http://localhost:8100/build/vendor.js:66020:65)
at Object.__webpack_exports__.c (http://localhost:8100/build/vendor.js:66020:156)
at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
at Object.<anonymous> (http://localhost:8100/build/vendor.js:65949:72)
at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
at Object.<anonymous> (http://localhost:8100/build/vendor.js:112662:64)
at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
at Object.<anonymous> (http://localhost:8100/build/vendor.js:65937:70)
at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
at Object.101 (http://localhost:8100/build/main.js:76:76)
Please help on this.
Thanks in advance