Hi Steven, your reply is very insightful. Kudos!
The perception I have about domain models is that a domain model class like
Book should have methods like update, delete, etc. The idea is that the
Book model should take care of itself. I've coded in C#/.NET and
PHP/Laravel, and we have coded relatively fatter models in both those
frameworks.
I guess that should not be the case in Angular2. Domain Models are just a
data structure and all manipulation should be done in appropriate service.
Isn't it so?
I've changed my original plans. I now use the domain models to define the
data structure. I call the service to create objects of those models and
manipulate them,
Model:
class Book {
id: number;
isbn: string;
name: string;
}
Component:
class BooksCreateComponent {
book: Book;
constructor(
private Books: Books
) {
this.book = new Book();
}
save() {
this
.Books
.create(this.book);
}
}
Values are assigned to the book property of the component from the view.
--
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.