我有一个Angular应用程序-我导入了js
import './components/print/Print';
import './components/file/File';
import './components/print/custom';
app.module 中的文件在ng build时有效,但是在使用"optimization": true , "aot": true, "buildOptimizer": true
时有效
不能工作
这是导入此文件的正确方法吗?如何解决这个问题?
应用模块:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, InjectionToken, } from '@angular/core';
import { FormsModule, ReactiveFormsModule, } from '@angular/forms';
import { AppComponent } from './app.component';
import {FormIOComponent} from './formio.component';
import {HttpModule} from '@angular/http';
import { FormioModule } from 'angular-formio';
import {routerConfig} from './app.router';
import { RouterModule } from '@angular/router';
import { HttpServices } from './services/http.services';
import { Globals } from './services/global.service';
import { NgxUiLoaderModule } from 'ngx-ui-loader';
//import { Liferay } from './model/liferay.model';
import '../styles.css';
import './components/print/Print';
import './components/file/File';
import './components/print/custom';
import { UserProfile } from './services/user.profile.service';
import { NgxSpinnerModule } from 'ngx-spinner';
import { APP_BASE_HREF } from '@angular/common';
@NgModule({
imports: [
BrowserModule,
ReactiveFormsModule,
FormioModule,
HttpModule,
NgxSpinnerModule,
NgxUiLoaderModule,
RouterModule.forRoot(routerConfig) ],
declarations: [ AppComponent, FormIOComponent],
bootstrap: [ AppComponent ],
providers:[HttpServices,Globals,UserProfile,{provide: APP_BASE_HREF, useValue : '/' }
//{ provide:Liferay, useValue: (<any>window).PORTAL},
]
})
export class AppModule {
constructor(){
}
}
custom.js
/**
* This file shows how to create a custom component and register that within an Angular application.
*
* Get the base component class by referencing Formio.Components.components map.
*/
import { environment } from '../../../environments/environment';
import ButtonComponent from 'formiojs/components/button/Button';
import Components from 'formiojs/components/Components';
import HTMLComponent from 'formiojs/components/html/HTML';
import PrintEditForm from './Print.form';
import { Formio } from 'formiojs';
/**
* Create a new CheckMatrixComponent "class" using ES5 class inheritance notation.
* https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Inheritance
*
* Here we will derive from the base component which all Form.io form components derive from.
*
* @param component
* @param options
* @param data
* @constructor
*/
export default class CustomHTMLComponent extends HTMLComponent {
setHTML() {
console.log("Called");
this.htmlElement.innerHTML = this.interpolate(this.t(this.component.content));
}
}
Components.setComponent('htmlelement', CustomHTMLComponent);