DevelopersPL / DevAAC

DevAAC for TFS 1.0
https://developerspl.github.io/DevAAC
MIT License
29 stars 16 forks source link

Can explain how that work. #18

Closed novasdream closed 9 years ago

novasdream commented 9 years ago

https://github.com/DevelopersPL/DevAAC/blob/master/public_html/modules/houses/houses.js

I check in angularjs docs and cant found something like that.

DevAAC.controller('HouseController', ['$scope', '$routeParams', '$location', 'House', 'Player', 'Server', 'info', 'house',
function($scope, $routeParams, $location, House, Player, Server, info, house) {

where it comes from 'House' ?

I can see house (lowercase) come from

house: function(House, $route) {
  return House.get({id: $route.current.params.id}).$promise;
}
TheSumm commented 9 years ago

House is this

  DevAAC.factory('House', ['$resource',
      function($resource){
          return $resource(ApiUrl('houses/:id'), {}, {
              get: { cache: true },
              query: { isArray: true, cache: true },
              bid: { url: ApiUrl('houses/:id/bid'), method: 'POST' }
          });
      }
  ]);

house is resolved here:

            house: function(House, $route) {
                return House.get({id: $route.current.params.id}).$promise;
            }
novasdream commented 9 years ago

@TheSumm So Player come from Factory in Player.js ?

where that code get data from webservice ?

DSpeichert commented 9 years ago

It's automatically fetched by ngResource from API. The URL is defined here:

return $resource(ApiUrl('houses/:id'), {}, {