3 ms·
I'd add a few more thoughts. Keep your controllers lean and mean. Put more of the UI logic into services. This makes testing a lot easier. Only use routing
by michaelw 13y ago
I'd add a few more thoughts.
Keep your controllers lean and mean. Put more of the UI logic into services. This makes testing a lot easier.
Only use routing ($route, $routeProvider) if your app has very little UI state and could reasonably thought of as several totally independent pages. I switched to managing $location.path() explicitly and haven't looked back.
Embrace promises throughout your app. Angular templates can now render promises naturally but I've found that I prefer to be more explicit:
$http.get(url).then(function(response) {
$scope.something = response.data;
}, function(error) {
$scope.$emit('error', error);
});
Wrapping jquery widgets in directives often results in more code than just doing it yourself. Obviously this increases your maintenance surface area but typically less than you would expect.
The Angular Bootstrap project is trying to create directives that avoid jquery and could be bound (with different templates) to other UI frameworks. What I really want is a core set of UI widget directives and then separate (bootstrap or foundation inspired or not) CSS libraries for styling them.
- joelhooks 13y agoreally good points. We were "promise shy" and I'm now completely sold and in love with them. We actually use a Command implementation that I ported, which has been really handy for leaning up the controllers, plus they aren't stateful so they are always available. https://github.com/joelhooks/js-command-center https://github.com/joelhooks/js-command-center.