Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs smart table st-safe-src attribute

I have gone through this link http://lorenzofox3.github.io/smart-table-website/. But i have not got the use case of "st-safe-src". when we need to use this attribute.

like image 231
user2428697 Avatar asked Jun 13 '15 13:06

user2428697


1 Answers

I believe this explanation could help you with st-safe-src :

1) You have a displayed collection (ie the repeater) which will be the result of sort, filter, slice operations on a base collection.

2) When initialised smart-table create a copy of the provided st-table collection as its base collection. So the sort,filter,slice are based on the original asset. When calling with ajax, you don't have the dataset at initialisation time so that the base copy is actually wrong. As a side node, I would rather fetch the data when resolving the controller dependencies (ie the resolve in the route) it will ease your unit tests

3) When using the st-safe-src you explicitly tells smart-table to watch and update its base collection ie the one it uses as the reference when sorting, filtering and slicing.

So basically the st-table is the displayed collection (the result) and st-safe-src is the base collection (the original dataset).

So if you set both to the same collection, the latest will be watched and will change the first one, which will trigger the watch...which will update the displayed one....etc.


Reference : https://github.com/lorenzofox3/Smart-Table/issues/156#issuecomment-54242437

like image 86
Nicolas Charpentier Avatar answered Nov 04 '22 23:11

Nicolas Charpentier