-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preline plugin components are not working properly in Angular when used inside structural directives #505
Comments
@StoyanZhulev Hi, Instead of relying on automatic initialization, you can create an instance of the component using the constructor and pass the necessary options directly. This allows you to initialize the component at the appropriate time, avoiding issues caused by the element being unavailable initially. I'm not a big Angular expert, but it seems that this approach should work:
|
@olegpix I have a similar issue with a treeView...tried following your example but seems not to work (I'm doing something wrong for sure) could you help me providing a similar example with a TreeView component? thanks in advance. |
@sureMOISE Even if you initialise it manually like olegpix suggests you should do it in the appropriate time - if your treeView is in an |
Summary
When a plugin component is used inside of a structural directive (@if or @switch) and the condition is not initially "truthy", the components are not working properly. A way around this is to use autoInit every time there's a change that affects the component, but this can add other issues as stated in other Issues like: #429 and #443
Is a more convenient way planned to be implemented or we have to stick to cleanCollection and autoInit?
Steps to Reproduce
The Pin-input or Strong password components can be used as example. If it is rendered initially on the screen it works as expected and shown in the documentation. However if it is wrapped in a structural directive and shown at a later stage the component is not working properly. The visual styles are applied, but the behaviour is broken.
Demo Link
Strong-password component:
https://stackblitz.com/edit/preline-v2-angular-cgqjqi?file=src%2Fapp%2Fpages%2Fpin-input%2Fpin-input.component.ts,src%2Fapp%2Fpages%2Fpin-input%2Fpin-input.component.ts,src%2Fapp%2Fpages%2Fstrong-password%2Fstrong-password.component.html,src%2Fapp%2Fpages%2Fstrong-password%2Fstrong-password.component.ts
Pin-input component:
https://stackblitz.com/edit/preline-v2-angular-cgqjqi?file=src%2Fapp%2Fpages%2Fpin-input%2Fpin-input.component.ts,src%2Fapp%2Fpages%2Fpin-input%2Fpin-input.component.ts,src%2Fapp%2Fpages%2Fstrong-password%2Fstrong-password.component.html,src%2Fapp%2Fpages%2Fpin-input%2Fpin-input.component.ts
Expected Behavior
The functional behaviour of the component to be the same as usual.
Actual Behavior
The functional behaviour of the component is broken.
Screenshots
No response
The text was updated successfully, but these errors were encountered: