Angular 2 sortable table using Semantic-UI -
i'm using semantic-ui in angular 2 app , trying add sorting functionality table. semantic-ui discusses here: http://semantic-ui.com/collections/table.html, , says this:
adding classname of ascending or descending th show user direction of sort. example uses modified version of kylefox's tablesort plugin provide proper class names. make sortable tables work, include javascript(1) page , call $('table').tablesort() when dom ready.
(1) = http://semantic-ui.com/javascript/library/tablesort.js
so, copied , pasted js code , put in angular 2 project in src > assets > tablesort.js
then edited angular-cli.json file scripts section includes this: "../src/assets/tablesort.js"
in table's html, set to:
<table class="ui sortable celled table">
in table's main component/ts file, after imports before component decorator, added this:
declare var $:any;
and last step seems adding code "when dom ready":
$('table').tablesort();
i've tried putting above line in constructor, in ngoninit(), in ngafterviewchecked(), , other parts of component lifecycle. keep getting error when app loads:
$(...).tablesort not function
i've read semantic links noted above, , seen older discussion on so, not sure else @ point.
can me working?
Comments
Post a Comment