I have started to learn Angular 2 and I am trying to figure out how to best
setup the various parts, and I now have basically three questions.
So let's say we have a simple user app. Basically: create account, log in,
log out, see/change own profile, list and search other users and see other
users profile.
*1. How would could we structure this best by feature?*
Perhaps something like this? (for simplicity, I have all html and css
inline in the component, otherwise just split "..../component/name.ts" into
3 files, with the additional ".../component/name.html" and
".../component/name.css")
/app/account/ -> This feature take care of login, logout, and when the
user is logged in, show the username and having a link to the profile
components/login.ts
components/logout.ts
services/account-service.ts -> Have as little logic in the
components as possible
/app/profile/ -> This feature shows a profile and lets the owner edit his
profile
components/profile.ts
services/profile-service.ts
/app/users/ -> This feature shows a list of users
components/users.ts
pipes/search-pipe.ts
services/users-service.ts
/app/server/ -> This feature enables other features/components do CRUD
services/server-service.ts
*2. But where would I put the models?*
In this case, I guess I really have only one model, a user-model. But where
would I put that? Maybe like this?
/app/server/services/user-model.ts
Or perhaps I should have 3 models, perhaps like this?
/app/account/services/account-model.ts
/app/profile/services/profile-model.ts
/app/users/services/users-model.ts -> This would be a list of profiles (or
a subset of profile)
Or perhaps even like this?
/app/server/services/account-model.ts
/app/server/services/profile-model.ts
/app/server/services/users-model.ts -> This would be a list of profiles (or
a subset of profile)
*3. A common server connection service*
Should this be a small class with some common stuff for setting up an
connection and let each feature/component extend this class and do the rest
of the server connection implementation?
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.