This is a migrated thread and some comments may be shown as answers.

k-visible versus ng-show or ng-if

5 Answers 267 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
CCG
Top achievements
Rank 2
CCG asked on 30 Jun 2015, 09:01 AM

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

Sort by
0
Petyo
Telerik team
answered on 02 Jul 2015, 07:04 AM

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
CCG
Top achievements
Rank 2
answered on 02 Jul 2015, 09:09 AM

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

0
Petyo
Telerik team
answered on 06 Jul 2015, 07:53 AM

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Plamen
Top achievements
Rank 1
answered on 01 Apr 2019, 12:34 PM

@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!

 

 

0
Veselin Tsvetanov
Telerik team
answered on 03 Apr 2019, 06:11 AM
Hello Plamen,

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
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
CCG
Top achievements
Rank 2
Answers by
Petyo
Telerik team
CCG
Top achievements
Rank 2
Plamen
Top achievements
Rank 1
Veselin Tsvetanov
Telerik team
Share this question
or