Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
686 views
in Technique[技术] by (71.8m points)

angular - Exporting pipes in a shared library

I created a shared library with some components, pipes, directives etc.

One of the modules exports a pipe, that is in turn exported in public_api.ts :

public_api.ts

[...]
export * from './lib/pipes/date/format/ob-date-format-pipe.module';
[...]

The module itself exports the pipe :

ob-date-format-pipe.module.ts

@NgModule({
  imports: [
    CommonModule,
  ],
  declarations: [
    ObDateFormatPipe,
  ],
  exports: [
    ObDateFormatPipe,
  ],
})
export class ObDateFormatPipeModule { }

This seems pretty standard.

Problem : when I create a version of this library, I can use the pipe but only from HTML ! If I try to import the pipe from TypeScript, the import ObDateFormatPipe from "@acme/framework" will not be resolved.

If I want it to work, I have to explicitly export the pipe, even if it is already exported from the module, like this :

[...]
export * from './lib/pipes/date/format/ob-date-format-pipe.module';
export { ObDateFormatPipe } from './lib/pipes/date/format/ob-date-format.pipe';
[...]

Is it normal or did I do something wrong ? Anything special with pipes ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...