In my factories.js file, I have the following code:
app.factory('CustomerCompany', function($resource){
return $resource('/customer_companies/:id.json', {id: "@_id"}, {
'query':{method: 'GET', isArray:false},
'getByCustomerAccount':{
method: 'GET',
params: {customer_account_id: customer_account_id},
isArray:true,
url:'/customer_companies/get_by_account/:customer_account_id.json'
}
});
});
The purpose of this code is to fetch a list of customer companies that belong to a specific customer account by supplying a customer_account_id.
When I look at my controllers.js file,
app.controller('customerAccountEditController', function($scope, CustomerCompany) {
$scope.data = {};
var path = $location.path();
var pathSplit = path.split('/');
$scope.id = pathSplit[pathSplit.length-1];
var customer_account_id = $scope.id;
$scope.list_of_companies = [];
CustomerCompany.getByCustomerAccount({customer_account_id: customer_account_id}, function(data){
console.log(data);
//$scope.list_of_delegates.push(data);
});
});
I encountered an error stating "customer_account_id not defined."
Where could I have made a mistake in my implementation?