Skip to content
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

Closed
picosam opened this issue Aug 27, 2017 · 5 comments

Comments

@picosam
Copy link
Contributor

picosam commented Aug 27, 2017

This error was present in the console even before you added StripeCardComponent. It happens the first time the stripe script is loaded:

[Log] TypeError: undefined is not an object (evaluating '_this.cardRef.nativeElement') (main.bundle.js, line 2715)
(anonymous function) — book-bedroom.component.ts:43
__tryOrUnsub — Subscriber.js:238
next — Subscriber.js:185
_next — Subscriber.js:125
next — Subscriber.js:89
_next — map.js:83
next — Subscriber.js:89
_next — filter.js:87
next — Subscriber.js:89
next — Subject.js:55
next — BehaviorSubject.js:44
onload — ngx-stripe.es5.js:78
wrapFn — zone.js:1075
onInvokeTask — core.es5.js:3881
runTask — zone.js:192
invokeTask — zone.js:499
invokeTask — zone.js:1427
globalZoneAwareCallback — zone.js:1445
@richnologies
Copy link
Owner

Hi, may I see your ts and html files to see whats going on?

@picosam
Copy link
Contributor Author

picosam commented Aug 27, 2017

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); });
	}
}

@richnologies
Copy link
Owner

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

@picosam
Copy link
Contributor Author

picosam commented Aug 27, 2017

I'll also do some more tests on different browsers tomorrow. For now, I can only claim this happens on Safari.

@picosam
Copy link
Contributor Author

picosam commented Aug 29, 2017

I believe this is really not occurring anymore; strange! Any news about the locale settings? Thanks!

@picosam picosam closed this as completed Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants