I have made a table with AngularJS all is working good pagination and sorting but i want to make it as a component so that in other pages it can be used. Right now i have made a factory which calls my API and controller and server side pagination is also implemented. Now what should be the way of making table as a tag like
2 Answers
You need to encapsulate your component and behaviours into an Angular Directive.
-
Directives are one of the key parts of AngularJS, you really need to read up on how they work, then creating a table directive becomes simple. Try starting here, it's a great introduction. Commented Oct 9, 2014 at 6:48
Take a look how the table #ngtasty is implemented. Docs : http://zizzamia.com/ng-tasty/ Table directive : https://github.com/Zizzamia/ng-tasty/blob/master/src/table/table.js