I'm trying to make my component generator more flexible by adding in an option to make it a custom form control. I have the options set up in the schema along with an x-prompt
object to provide the options. In my component template I try to do this
<% if( componentType === 'custom form control' ) { %>
<%- import { ReactiveFormsModule } '@angular/forms'; %>
<% } %>
and I get the following error
Cannot use import statement outside a module in C:\path\to\my-folder_name_.component.ts__tmpl__ while compiling ejs
I tried looking into it and I could only find things regarding the issue on using import
in commonjs
projects. I set the type
property in my package.json
file to module
and I'm still getting this problem. I'm new to working with this level of NX and am having a hard time finding info that dives deeper into this, can someone help?
If
import { ReactiveFormsModule } '@angular/forms';
is the desired output of the template when the conditional is true, then it should not be wrapped in a template tag.
<% if( componentType === 'custom form control' ) { %>
import { ReactiveFormsModule } '@angular/forms';
<% } %>