Thanks for the response. Could you provide a more detailed response?  I've 
understood the i can inject the parent component to child to read the 
instance variable of parent, but i cannot understand how.

Il giorno mercoledì 29 luglio 2020 alle 15:39:13 UTC+2 bastien...@gmail.com 
ha scritto:

> What you can do is provide the parent:
>
> @Component({
>    providers: [
>     {provide: DynamicParent, useExisting: forwardRef(() => 
> ParentComponent)}
>   ]
> })
> class ParentComponent implement/extends DynamicParent {}
>
> @Component()
> class ChildComponent {
>   constructor(private parent: DynamicParent) {}
> }
>
> *Bastien Lemaire*
>
>
> On Wed, 29 Jul 2020 at 15:32, Andrea Zanti <plusmen...@gmail.com> wrote:
>
>> Yes, but my parent component is dynamic. Is possible to have parent ref 
>> from child?
>>
>> Il giorno mercoledì 29 luglio 2020 alle 13:42:01 UTC+2 
>> bastien...@gmail.com ha scritto:
>>
>>> Hi
>>>
>>> You could inject the parent component into the child component and read 
>>> from/write to to parent component's controller:
>>>
>>> @component()
>>> class Parent {}
>>>
>>> @Component()
>>> class Child {
>>>   constructor(private parent: Parent) {}
>>> }
>>>
>>> *Bastien Lemaire*
>>>
>>>
>>> On Wed, 29 Jul 2020 at 12:38, Andrea Zanti <plusmen...@gmail.com> wrote:
>>>
>>>> Hi everyone,
>>>> I have a parent component in which i define a logic. The child 
>>>> component instead is always the same and it receives always the same props 
>>>> from the parent.
>>>> I explain better. Here an example:
>>>>
>>>>
>>>> <parent-component>
>>>>    <child-component prop1="prop1" prop2="prop2" ...... again>
>>>>    </child-component>
>>>> </parent-component>
>>>>
>>>> Form my instance:
>>>>
>>>> <app-login>
>>>>     <app-form
>>>>       [form]="form"
>>>>       [model]="model"
>>>>       [fields]="fields"
>>>>       [submit]="submit.bind(this)"
>>>>       [url]="url">
>>>>      </app-form>
>>>> </app-login>
>>>>
>>>> N.B: All the props passed on the app-form component are defined in the 
>>>> parent component ( They are alway the same!!)
>>>>
>>>> App form is like a placeholder for the form , logic is always the same: 
>>>> it sends the request to the api , and handles error showing them in the 
>>>> inputs (inline error-forms).
>>>> The parent component defines the html thanks to the ng-formly package, 
>>>> and define behaviour after the submit.
>>>>
>>>>
>>>> *Now i want to know if is possible to avoid to redefine everytime all 
>>>> the props.*
>>>> *Something like getting all useful props from parent.*
>>>>
>>>> *The final result should be like this: *
>>>>
>>>> <app-login>
>>>>     <app-form
>>>>      </app-form>
>>>> </app-login>
>>>>
>>>>
>>>> Thanks in advance!
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Angular and AngularJS discussion" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to angular+u...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/angular/a0f494e6-bf85-4eaf-a389-d769ede82a68n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/angular/a0f494e6-bf85-4eaf-a389-d769ede82a68n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Angular and AngularJS discussion" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to angular+u...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/angular/28680ea1-588c-494f-9937-4f4072243ab8n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/angular/28680ea1-588c-494f-9937-4f4072243ab8n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/a7d958c8-bfaf-4089-a3ab-fd9c95147e76n%40googlegroups.com.

Reply via email to