Thank you for your answer. I think I will create an wrapper view model to be more flexible. Creating a directive is not a possible solution in my situatioin. (The data is not passed back to the server)
2014-10-21 23:30 GMT+02:00 Eric Eslinger <eric.eslin...@gmail.com>: > That kind of depends in general. As Nicholas pointed out, you may end up > posting those transient view values back to the server for persisting, > which could be ignored or could throw an error or (worse of all) get > persisted if you're going fully schemaless (but at that point, you have a > pretty big problem with over-trusting). > > The other issue you can run into is with a model cache. Personally, I end > up cacheing XHR responses, so Profile.get(1) will only incur one $http > request per lifecycle, but that means if I store view variables on the > profile object, those view variables end up being persisted if you click > away and see the same object in a new context. > > Personally, I store no view variables on models. What I do, especially if > I have to ng-repeat over a list of items where each item has some transient > view state information (like expanded or hidden, rather than the model > stuff like productId), is define a custom directive for displaying the > item. Sometimes, these directives only get used in one place (but I usually > end up finding new uses for them). That way, I can pass in the item to > display (Profile or Document or whatever) as an '=' scope (usually) > assignment, and set view variables in the directive's isolate scope. > > It's a little more work, but ultimately leads to a nice separation of > concerns with my code. > > e > > On Tue, Oct 21, 2014 at 2:13 PM, Nicholas Smith <nick.sm...@gmail.com> > wrote: > >> One issue to watch out for is if you try to send those objects back to >> the server through the rest API, you might have an issue with those new >> fields being sent to your API. Depending on how your back-end is >> implemented it might just ignore the fields, but it could cause errors. >> >> >> On Tuesday, October 21, 2014 6:41:40 AM UTC-5, Jens Hoffmann wrote: >>> >>> hello, >>> >>> in my application there is a rest api which gets a product object. >>> >>> { >>> "Product": { >>> "productId": 181124961, >>> "erpNumber": "1231124", >>> "price": 34.99 >>> >>> } >>> } >>> >>> My question is now is it ok to extend this model like so, or is it >>> better to create an additional layer for that (wrapper viewmodel): >>> >>> >>> { >>> "Product": { >>> "productId": 181124961, >>> "erpNumber": "1231124", >>> "price": 34.99, >>> "_chosenOptions": {124214, 1241241}, // own properties marked >>> with "_" >>> "_selectedQuantity": 1 >>> >>> } >>> } >>> >>> >>> >>> best regards, >>> >>> jens >>> >>> >>> >>> -- >> 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 angular+unsubscr...@googlegroups.com. >> To post to this group, send email to angular@googlegroups.com. >> Visit this group at http://groups.google.com/group/angular. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to a topic in the > Google Groups "AngularJS" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/angular/83eJbQBQvuQ/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > angular+unsubscr...@googlegroups.com. > To post to this group, send email to angular@googlegroups.com. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- 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 angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.