-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: undefined is not an object (evaluating '_this.cardRef.nativeElement') #4
Comments
Hi, may I see your ts and html files to see whats going on? |
Sure, here you go: <form [formGroup]="formGroup" role="form" (ngSubmit)="buy()">
<label>
<span>Name</span>
<input formControlName="name" class="field" />
</label>
<ngx-stripe-card [options]="cardOptions"></ngx-stripe-card>
</form> import {Component, OnInit, ViewChild} from '@angular/core';
import {StripeService, StripeCardComponent} from 'ngx-stripe';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
@Component({
templateUrl: './book-bedroom.component.html',
styleUrls: ['./book-bedroom.component.css']
})
export class BookBedroomComponent implements OnInit {
formGroup: FormGroup;
@ViewChild(StripeCardComponent) card: StripeCardComponent;
cardOptions = {
style: {
base: {
iconColor: '#666EE8',
color: '#31325F',
lineHeight: '40px',
fontWeight: 300,
fontFamily: 'Lato',
fontSize: '18px',
'::placeholder': {
color: '#CFD7E0'
}
}
}
};
constructor(private fb: FormBuilder, private stripeService: StripeService) {}
ngOnInit() {
this.formGroup = this.fb.group({
name: ['Jane', Validators.required]
});
}
buy() {
const name = 'Jane';
console.log('card');
this.stripeService.createToken(this.card.getCard(), { name })
.subscribe(token => {
console.log('Token created correctly');
console.log(token);
}, error => { console.log(error); });
}
} |
I cannot reproduce the error on my laptop. I will give it a try tomorrow at the office on some Virtual machines and get back to you |
I'll also do some more tests on different browsers tomorrow. For now, I can only claim this happens on Safari. |
I believe this is really not occurring anymore; strange! Any news about the locale settings? Thanks! |
This error was present in the console even before you added
StripeCardComponent
. It happens the first time the stripe script is loaded:The text was updated successfully, but these errors were encountered: