简体   繁体   中英

Getting ReferenceError: HTMLInputElement is not defined with Angular 4 Universal

I have an app running on Angular 4 that I'm running on CDN. I'm trying to port it to Angular Universal because Google crawler isn't doing a very good job crawling my site. I'm running into the below error when trying to run my Node server script,

@ViewChild('text') text: HTMLInputElement;

ReferenceError: HTMLInputElement is not defined

I think it has to do with the Node engine not knowing what HTMLInputElement is, because it is native to the browser. Is there anyway I can import that or add a package so Node would recognize that?

Many thanks in advance.

Probably to late, but just to answer this question, you should use

@ViewChild('text') text: ElementRef;

and

import { ElementRef } from '@angular/core';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM