You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been favoring the .service method for exposing model resources in my application.
(function(){'use strict';angular.module('common.resources').factory('Article',ArticleFactory).factory('Comment',CommentFactory)////////////////////functionArticleFactory(Restangular){varresourceUrl='articles';varArticle=Restangular.service(articles);// my current solution - tack on an attribute to the generated serviceArticle.resourceUrl=resourceUrl;Restangular.extendModel(resourceUrl,function(model){// add some "article" methods here});returnArticle;}////////////////////functionCommentFactory(Restangular){varresourceUrl='comments';varComment=Restangular.service(resourceUrl);// my current solution - tack on an attribute to the generated serviceComment.resourceUrl=resourceUrl;Restangular.extendModel(resourceUrl,function(model){// add some "comments" methods here});returnComment;}})();
In my application code, I want to retrieve comments subresources under a particular article resource. I'm currently building the URL via option 1 below. I tack a "resourceUrl" onto the resource, so as to not carry a bunch of magic strings throughout the application.
Is there any other best practice way to use the URL builder to chain services? It's a minor inconvenience, just wondering if anyone has a different approach.
functionController(Comment,Articles){// hard-coded for simplicity in this examplevararticleId=1;// current solution - option 1// GET /articles/1/commentsArticle.one(articleId).all(Comment.resourceUrl).getList();// alternative syntaxes (don't work, just curious if there's some other way to accomplish this)// Article.one(articleId).all(Comment).getList();// Article.one(articleId).all(Comment.getList()).getList();}
The text was updated successfully, but these errors were encountered:
I've been favoring the .service method for exposing model resources in my application.
In my application code, I want to retrieve comments subresources under a particular article resource. I'm currently building the URL via option 1 below. I tack a "resourceUrl" onto the resource, so as to not carry a bunch of magic strings throughout the application.
Is there any other best practice way to use the URL builder to chain services? It's a minor inconvenience, just wondering if anyone has a different approach.
The text was updated successfully, but these errors were encountered: