Express.js angular.js

angular.module('App').factory('Blogs', ['$resource', function($resource) {
    return $resource('/api/blog/:blogId/:catId/:search/:pagenum' , {
             blog: '@blogId',
                  page: "@pageController",
                  pagenum: '@pagenum'
      },
      {
            Page: {
                  params: {
                    pageController: "page"
                  }
                },
            Cat: {
                  params: {
                    catController: "cat",
                    catId: 'catId'
                  }
              }
      });
}]);

I have made the above service in angularjs , can i access the page method defined in it in my controller i.e can i call Blogs.Page/Blogs.Cat in my controller.

Answers


Yes of course, you can use it like this:

function PageController($scope, Blogs){
 Blogs.Page(function(response){
   $scope.pages = response;
 });
}

Also can be params:

function PageController($scope, Blogs){
 Blogs.Page({ id: 3}, function(response){
   $scope.pages = response;
 });
}

I've recommended to you see: Restangular repo, How use: video from developers


Need Your Help

Knockout JS failed to update observableArray

javascript html knockout.js knockout-templating

So I'm trying to add content to an observable array, but it doesn't update. The problem is not the first level content, but the sub array. It's a small comments section.

How to expose variable from HAL to shared libraries present in system/lib/hw (android)?

android android-audiomanager hal

I made some changes in the platform specific existing HAL, and I want this changes to be get selected when I start my audio stream.