typescript - Angular 4 cannot see value accessor when the component is from foreign module -


i got 2 npm packages: components , app. components 1 supposed contain reusable components used across multiple apps. want of components play ngmodule.

i've got test control defined that:

/// components package

export const value_accessor: = {   provide: ng_value_accessor,   useexisting: forwardref(() => testcontrolcomponent),   multi: true };  @component({   selector: 'test-control',   templateurl: './test-control.component.html',   styleurls: ['./test-control.component.scss'],   providers: [ value_accessor ] }) export class testcontrolcomponent implements oninit, controlvalueaccessor { ... } 

testcontrolcomponent has interface elements no-op (i skipped them brevity).

and in module exported that:

@ngmodule({   imports: [   ],   declarations: [     testcontrolcomponent   ],   exports: [    testcontrolcomponent   ] }) export class componentmodule {} 

and consumed so:

// app package

app.module.ts:

import { componentmodule } '@company/components'; import { formsmodule } form '@angular/forms'  @ngmodule({    imports: [ formsmodule, componentmodule ],    ... }) 

and usage in component declared in app.module.ts:

<form #testform="ngform">   <test-control name="name" [(ngmodel)]=""></test-control> </form> 

this results in app compiling @ runtime throws core.es5.js:1020 error error: uncaught (in promise): error: no value accessor form control name: 'test' error: no value accessor form control name: 'test' , imported control stops working. if copy control app package , declare in app.module.ts - works.

the value accessor there, have idea why angular cannot recognize this?

can try importing formsmodule imports: [] array of componentmodule declaration? seems ngmodel attribute used in <test-control></test-control> tags part of componentmodule doesn't have required modules imported work. (actually meant add comment wouldn't let me yet).


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -