So I've set up a factory like so using $resource:
'use strict';
angular.module('hscApp')
/* ----------------------
Test- Using channel_id
------------------------ */
.factory('Data', function($resource){
return {
retrieve: function() {
params = {
status: 'upcoming',
followed: 1,
reason: 1,
views: 1,
per_page: 2,
channel_id: 2165604
};
return $resource('/api/v1/channel_listings.json', params);
}
};
})
The format of the API is something what I have listed below:
api/v1/channel_listings.json?status=upcoming&followed=1&reason=1&views=1&per_page=2&channel_id=2165604
I "think" I have this set up correctly, but I'm not really sure. The goal is to have dynamic parameters to pass into this factory (namely the channel id). I set up my controller like:
'use strict';
angular.module('hscApp')
/* main controller */
.controller('MainCtrl', function ($scope) {
$scope.$on('$viewContentLoaded', angularOnLoad);
})
.controller('TestCtrl', function(Data){
$scope.Data = Data.retrieve({
status: 'upcoming',
followed: 1,
reason: 1,
views: 1,
per_page: 2,
channel_id: 216560
});
Data.get(function(data){
$scope.upcomingEvents = data;
});
});
Then I'm trying to display a field from the JSON by doing {{ event.name }} but I'm getting errors saying Data is not defined. Am I doing something wrong here?