After making almost 100 controllers for one system, we’ve established a standardized method for controllers. It’s not complex or exciting, but it’s saved us enough time that we decided to keep it on our site.
Telerik offers a fantastic library called Kendo UI. They’ve converted all of the objects into Angular Directives. They’re great, except there are some issues that really arise from the actual platform. Angular is very data-centric. You don’t pick an object and then change it, as you do in jQuery, you define the parameters of the object as variables and then let the data do the work naturally.
Using Kendo ObservableArray’s lets us avoid unnecessary constructs that just don’t ever seem to work out for us in AngularJs.
To make our code as easy to maintain as possible, we keep all data interactions in modules called Factories. Most of our factory files have about 10 or 12 callback functions and we try to keep them pretty simple. Moving them to typescript wasn’t very intuitive at first, but once we figured it out, it is a no-brainer.
Here’s a basic sample that we used to get a list of offices from the api server. You can add as many functions as you want.