vendredi 17 avril 2015

How get data with angular and send it with node.js?

I'm changing my node.js application, i was using EJS template engine and now i want use angular.


For this i already install angular and is working good, but now i want get my data, and for this i'm using the $http service:



(function($) {
app.controller('EventCtrl', ['$scope', '$http', function($scope, $http){
$scope.data;

$http.get('/data').
success(function(data, status, headers, config) {
$scope.data = data;

}).
error(function(data, status, headers, config) {
$scope.data = data;

});

}]);

}(jQuery));


And i'm sending the data in the backend:



restAPI.GET(options).then(function (result) {
res.render('data/index.html', {
event: result,
});
}).then(undefined, function (error) {
console.log(error);
});


But its returning the HTML from the same page that i'm using the controller. What am i doing wrong here??


Aucun commentaire:

Enregistrer un commentaire