angular-styleguide
angular-styleguide copied to clipboard
Template Style Guide
John, Great guide! And great PluralSight course! I've learned a lot from all this so far and I'm working on daily Kata to reinforce what I've learned. Thanks for putting all this out there!
I was looking for guidance on Templates - style, naming, usage, when/how to use directive/component in Angular 1. Did not find explicitly in the style guide.
interesting ideas. perhaps the community can suggest some topics and make some PRs.
So far in the past few months, I've been using components exclusively without any issues. Perhaps there will be a case in the near future when a directive will be necessary because of some linking or DOM manipulation that is necessary.
So far, for naming, I've been using the component/directive name as the file name but tacking on -view to the end. For example, for an address component, I'm using "address-view.html". I don't believe the file extension matters for angular. Maybe it would be better to use .view or .template instead but an IDE or editor may not format it nice and pretty.
Was thinking of dropping the "-view" part of the names but sometimes might not be clear what the file is really for. Think of "file.html" for instance - "file-view.html" might clear things up better. And especially in the directive tag
Generally, the Angular guides use something like
Then there's namespacing...angular uses ng-... for its templates. I might use pv- or n5d- or perhaps company name like acme-address.
So perhaps best to use something like
That's what I've found works best for me so far anyways, still learning though and would be great to hear from others on this topic. Thanks!