last day (14 days later) » 

4:33 PM
0
Q: Accessibility parent component from child component when parent component using ng-content Angular

Tran Khanh NguyenI'm trying to access parent component from child component using dependence injection. It works, I can access to parent to using its methods and properties but I have not seen this approach on Angular doc. So do you have any idea about this approach? Should I use it? Because the parent component...

 
you have messed up the components with <ng-content> at all places. can you share the image layout which you are trying to achieve.
 
It should be a normal wizard with many steps, then we can go next, go back step. And in each step, we have different html design so that why I'm using ng-content. Sorry, I don't have image of layout, I'm working on it. Thanks
 
if you can elaborate on your concern, may I can help you out
 
My concern is that I can inject parent component from a child component like inject service in Angular but I have not seen this approach on Angular doc. So I don't know it's good or bad?
 
are you available in team viewer?
 
4:33 PM
Sorry I am not. I'm using mobile. Btw thank you very much for your comments ;)
 
hi
 
Hey Aravind
 
what is your exact expectation?
 
Let me explain my situation again
 
ok
 
4:36 PM
I'm creating a component with ng-content
When using it I want to put some another component into its content
As i wrote on question
Wizard and step components
 
is this ur expectation?
 
u complicated using <ng-content>
 
I tried to find how to communicate between them
 
by communicate what you mean?
I will update my answer check if it is serves your requirement
 
4:40 PM
I mean when step(child cmp) init, it will push to wizard steps variable
So i found the way that i will inject Wizard cmp into Sep cmp constructor
 
what will the step component emits to Wizard?
 
By this way i can access Wizard cmp properties and methods
Wizard will store an array of step
 
ok. on which event step will emits to wizard?
 
Once i access to Wizard i can use its method (addStep) to add step into that array
It emit as the time construct Step cmp
I mean in constructor
 
wizard will add a step right?
at that time what the step will react back?
 
4:45 PM
But have you ever seen we can inject a component from a component?
Yep that's right
 
yes. I can work for you one last question
lets assume initially 3 steps are there, when u create a step your wizard should have 4 steps correct?
 
We just store a list of step then we click next or back button it will update step in this steps array
 
ok. cool.
i will give u a solution check if it helps u
 
Ok thank you
Super kind ;)
 
give me five mins
ok?
 
4:50 PM
It's midnight at my time zone. So I will check your answer tomorrow. Is it ok
 
nope.
just five mins
dude
 
Ok i will wait thanks
 
5:01 PM
done
dude
there?
 
Hey
Thanks for your effort
 
you got the answer?
did u see the plunker?
 
Yep i did
 
was that you expected?
 
But i have different html layout for each step
 
5:11 PM
see the same plunker
 
So i cannot use ngFor
 
what are the differences?
 
Html design
Not just data from step
 
ok. I will help you in that now you want or?
tomorrow?
 
really
I appreciate that
 
5:13 PM
yes. it is very simple dude.
u need to use ng-content in the steps component alone.
 
Tomorrow is fine for me because i need to sleep now
Yep
That why i use ngcontent
 
I will update the post you see tomorrow
ok ?
 
Looking forward to seeing your solution
Sure
See you
 
bye
r u happy?
I will update in ten mins
 

last day (14 days later) »