I am new to mean and and i am able to apply CRUD operations. Now I want to call more actions from Node JS controller from view that is Angular JS and I am refering this link https://github.com/jpotts18/mean-stack-relational for core model.
this is controller file design.js
exports.get_designs = function(req, res) {
console.log('in design node controllrrrrr get designs');
db.designs.findAll({ where: {competition_id: req.params.competitionId} }).success(function(designs){
return res.jsonp(designs);
}).error(function(err){
return res.render('error', {
error: err,
status: 500
});
});
};
In Angular controller
angular.module('mean.designs').controller('DesignsController', ['$scope', '$routeParams', '$location', 'Global', 'Designs',function($scope, $routeParams, $location, Global, Designs) {
$scope.global = Global;
$scope.get_init_records = function() {
console.log('in get init records comp id : ' + JSON.stringify($routeParams.competitionId));
Designs.query({
competitionId: $routeParams.competitionId
}, function(designs) {
console.log(designs);
$scope.designs = designs;
});
};
}]);
and in services design.js
angular.module('mean.designs').factory("Designs", ['$resource', function($resource) {
return $resource('designs/:designId', {
designId: '@id'
}, {
update: {
method: 'PUT'
}
});
}]);
In view
<section data-ng-controller="DesignsController" data-ng-init="get_init_records()" />
I can be able to call get_init_records this init method but later I dont know what is happening there ... and when I googled results like use $http but how to do this ? Thanks for help