i have regExp in constants:
export const Constants = {
QUERY_PARAM_CONFIG: {
REGEX: /\+/gi,
REGEX_ENCODED: /%2B/g
}
};
but when i run ng build i get an error:
ERROR in app\app.module.ts(58,21): Error during template compile of 'AppModule'
Expression form not supported in 'Constants'
'Constants' contains the error at app\configuration\constants.ts.
npm build script:
ng build --prod --output-hashing none --sourcemaps=true
any ideas?
The regex literals are not supported by AOT. See the list of supported syntax.
In order to make it work transform your regex to something supported e.g. string:
By this you can still pass the meaning of the RegExp and create one on the fly whenever you need them in the runtime