Closed jayordway closed 5 years ago
Thanks for reporting! Does this work with am-moment 3.2.0?
@urish I tried both 3.2.0 and 3.3.0 and experienced the same error when doing an AOT build with both versions.
Thanks for the info, did you add ModuleModule
to your imports in every single module where amDateFormat
is used?
import { MomentModule } from 'ngx-moment';
@NgModule({
imports: [
MomentModule
]
})
@urish Yes, I did actually, but I placed it in the app.module.js since I am not using lazy loading.
And does it work correctly without AoT? Does the app run without any errors and does amDateFormat
function correctly there?
@urish Yes it does
Do you have node_modules/ngx-moment/ngx-moment.metadata.json
?
If so, does node_modules/ngx-moment/package.json
include a metadata
field with reference to this file?
@urish Yes, all that is correct.
I tried the following, but couldn't reproduce:
ng new ngx-moment-test
cd ngx-moment-test
yarn add moment ngx-moment
then added MomentModule
import to my app.module.ts
, and the following code to app.component.html
:
Welcome to {{ title | amDateFormat }}!
Built the project with ng build --prod
and it compiled successfully. Perhaps you can try to follow the above steps and see if you still get the error when compiling?
@urish I have discovered that the problem was because I had the ivy rendering enabled in the tsconfig, without that everything builds without an error. I had to remove:
"angularCompilerOptions": { "enableIvy": true }
from the tsconfig.json.
Not sure why it was closed because with Angular Ivy it's still not working. Would be appreciated if you might upgrade this dependency so it won't break anymore.
Angular 7.2.15 moment 2.24.0 ngx-moment 3.4.0
When running $ng build --prod I see this error:
ERROR in : Template parse errors: The pipe 'amDateFormat' could not be found ...
If I run the build without aot such as:
ng build --prod --aot false --build-optimizer false
The project will build successfully. This is with ngx-moment 3.3.0 and here is my env info:
Angular CLI: 7.1.2 Node: 10.13.0 OS: darwin x64 Angular: 7.1.2 ... animations, cli, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, platform-server, router
Package Version
@angular-devkit/architect 0.11.2 @angular-devkit/build-angular 0.11.2 @angular-devkit/build-optimizer 0.11.2 @angular-devkit/build-webpack 0.11.2 @angular-devkit/core 7.1.2 @angular-devkit/schematics 7.1.2 @angular/cdk 7.1.1 @angular/material 7.1.1 @ngtools/webpack 7.1.2 @schematics/angular 7.1.2 @schematics/update 0.11.2 rxjs 6.3.3 typescript 3.1.6 webpack 4.27.1