Hi.
What is the preferred way of hiding/showing kendo controls in Angular? There are some options:
- ng-show
- ng-if
- k-visible
Beside the obvious difference between the first two, what are the complications of hiding/removing a wrapper DOM element as opposed to using k-visible. Are there any differences in performance, memory usage, etc. to be aware of?
Cheers,
JH
5 Answers, 1 is accepted
Hello,
k-visible is not an universal directive - it is a configuration option of the window. The most reliable means to hide/show Kendo UI widgets would be to use ng-show on a parent element/wrapper. ng if "removes or recreates a portion of the DOM tree based on an {expression}", which is not optimal for a widget.
Regards,Petyo
Telerik

Hi,
Thanks for the answer.
Is it possible to specify in more details what effect using ng-if on a parent element would have for the widget-object?
And should we avoid it altogether?
BR
Hello JH,
the ng-if directive will most likely destroy/instantiate the widget each time the value changes. We haven't explored its behavior in details, as it is very sub-optimal and has a very reasonable alternative.
Regards,
Petyo
Telerik

@Petoy.
I use ng-if to recreate widgets once they are destroyed.
For example: if I destroy a window on close and want to recreate it from $onChange() hook, the only way I am able to do so is by using ng-if.
What is a "reasonable alternative" to recreate destroyed widgets, without re-initializing components?
Thank you!
Using ng-if in the described scenario seems to be the appropriate approach. By mentioning "reasonable alternative", I believe that my colleague Petyo refers to the use of ng-show on a parent element/wrapper. That concerns the case in which the Window widget is not destroyed and therefore, it does not need to be recreated.
Regards,
Veselin Tsvetanov
Progress Telerik