6 ms·
I too have built a reasonably sized Angular app in the last year [1] and echo a lot of these thoughts. I'll add a few of mine: 1. For CSS, honestly for any pro
by cletus 13y ago
I too have built a reasonably sized Angular app in the last year [1] and echo a lot of these thoughts. I'll add a few of mine:
1. For CSS, honestly for any project it'd be hard for me not to simply use Bootstrap and be done with it and then do the minimum CSS possible (I say this as someone who has been doing CSS for years). Bootstrap really is the de facto CSS for the modern Web;
2. Organization: I agree the angular-seed project (which I started with and still use) isn't suited to organizing large projects and I agree separating into functional modules is the way to go;
3. Directives are awesome but to get all the two way data binding working requires a fairly deep understanding of how they work (to get the correct combination of scopes, transclusion, etc);
4. Directives also have limits that are sometimes annoying. You still can't generate definition list items with an ng-repeat, for example (a template has to have one top-level element). A solution to this is coming;
5. There's no good way of both just including code and using the parent scope plus some extras. This is done for reasons of code separation but there really is a use case (IMHO) for includes vs imports for templates;
6. $resource has no HTTP PUT method;
7. I'd probably avoid $resource altogether although it looks attractive. Use rich objects [2] instead;
8. Angular allows you to use a bunch of different other frameworks but it doesn't always play completely nice with them. Take the popover in Bootstrap. The way this works is by moving an element around in the DOM. This doesn't lend itself to a "nice" Angular directive (my version at least is kind of a hack).
9. Underscore.js is awesome. Use it;
10. Try to limit yourself to using jqLite that Angular comes with rather than full jQuery. This isn't really possibly with any reasonable part of Bootstrap however;
11. Isolate scopes in directives results some weird and unexpected behaviour. For example, if you reference something with an attribute, it'll work if it's an object (including an array) but won't with a simple value, requiring you to put such values in objects just so the directive can get a reference to it. This tripped me up a few times;
12. Scopes aren't always truly isolated either. For example, you can get tripped up by this if you have two attribute directives on the same element.
[1]: for those who follow IO, I am the Tech Lead of the Open Bidder project at Google (http://googleadsdeveloper.blogspot.com/2013/05/announcing-open-bidder-beta-platform.html http://googleadsdeveloper.blogspot.com/2013/05/announcing-op...)
[2]: http://stackoverflow.com/a/11850027/18393 http://stackoverflow.com/a/11850027/18393
- jonny_eh 13y ago$resource is really cool, but a bit half-backed. I recommend you check out Restangular, it makes using $resource a lot easier. https://github.com/mgonto/restangular https://github.com/mgonto/restangular
- aidos 13y agoAmazing. Was just in the middle of implementing my own resource factory but this one looks like just the ticket. Dropping it in to my project now. Thanks, you've probably just saved me a couple of hours.
- beggi 13y ago10. Try to limit yourself to using jqLite that Angular comes with rather than full jQuery. This isn't really possibly with any reasonable part of Bootstrap however; Can you explain this better?
- mcrittenden 13y agoIf you don't include jQuery then Angular falls back to its own home-grown mini-jQuery that they call jqLite, which contains a few essential functions of jQuery. GP was saying that it's sometimes wise to try and only use jqLite if you don't really need some more advanced parts of jQuery. This is presumably to save bandwidth.
- jskulski 13y agojQuery is very large if all you are using is the selector engine and some DOM manipulation.
- ganarajpr 13y agoAngular renders the most used parts of JQuery useless, if you use Angular the "right" way. If we do consider it, two of the most used parts of JQuery are $.ajax and querying the DOM. Because angular already provides you $http and $resource which are more than capable of doing everything that $.ajax does - $.ajax and all its variant that JQuery brings in become redundant. Because of the way Angular is and because of its philosophy of directives - You generally dont need to query the DOM at all most of the time ( like 90% of the time ). For the rest of the 10% of the time when you do need to query the DOM, you only need to go one step below a directives element (direct children). If you are doing anything more complex, then you are doing something wrong again. For this basic case, Angular already provides you JQLite which is capable of doing the querying for simple scenarios like this. About the helper functions that JQuery provides - angular too provides quite a few helpers - and they are sufficient for like 95% of the cases. For other stuff you might want to consider underscore. So, why do you need to include JQuery?