angular-styleguide icon indicating copy to clipboard operation
angular-styleguide copied to clipboard

Template Style Guide

Open philn5d opened this issue 7 years ago • 2 comments

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.

philn5d avatar Jul 20 '16 12:07 philn5d

interesting ideas. perhaps the community can suggest some topics and make some PRs.

johnpapa avatar Sep 05 '16 17:09 johnpapa

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 v .

Generally, the Angular guides use something like for a list of entities and for the details of each entity in the collection.

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 with the template file named "acme-file-detail.html" with that file located in the same directory as the js.

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!

philn5d avatar Sep 06 '16 03:09 philn5d