How can I communicate between angular and nodejs?


Node: app.js

var http = require("http");
var MongoClient = require('mongodb').MongoClient;
var express = require('express');
var app = express();
var mongoose = require('mongoose');
var url = 'mongodb://localhost:27017/webshop';
var assert = require('assert');
var products = mongoose.model('products', {
category: String,
type: String,
nme: String,
socket: Number,
clock: Number
app.listen(3000, function () {
    console.log('Example app listening on port 3000!');
app.use(express.static(__dirname + '/public'));
app.get('/products', function (req, res) {
    //Lets try to Find all products
    products.find(function (err, userObj) {
        if (err) {
        } else if (userObj) {
            console.log('Found:', userObj);
        //res.sendFile('views/aboutus.html', {root: 'public',data:userObj});
        } else {
            console.log('Products not found!');


<!DOCTYPE html>
<html lang="en" ng-app="WebShop">
<meta charset="UTF-8">
<link href="../bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="../bower_components/bootstrap/dist/css/bootstrap-theme.css" rel="stylesheet" type="text/css">
<link href="../stylesheets/style.css" rel="stylesheet">
<script src="../bower_components/jquery/dist/jquery.min.js"></script>
<script src="../bower_components/bootstrap/dist/js/bootstrap.min.js">    </script>
<script src="../bower_components/angular/angular.min.js"></script>
<script src="../javascripts/app.js"></script>
<body ng-controller="mainController">
    <tr ng-repeat="product in products">


var app = angular.module('WebShop', ['ngResource', 'ngRoute']);
app.controller('mainController',function($scope, $http,Products) {
var products = Products.get();
    .success(function (data) {
        console.log("http get products");
        $scope.products = data;
    .error(function (data) {
        console.log('Error: ' + data);

app.factory('Products', ['$resource', function($resource) {
return $resource('/products', null,
        'get': { method:'get' }

So my problem is...when i go to /products I get the json object on the webpage...but I would like to use the angular and the html I would like to get the array in angular and i would like to view on the screen with using the products.html....but now i see just the array of objects. Can anybody helps to me? I think i not understand the communication between AngularJs and NodeJS. And I not really know how to send to angular and how to display the result with using html with angular tags/attributes. Thanks a lot!

You are returning a JSON user object as a response and expecting an array, JSON is javascript object notations, so it is like an associative array, it seems that you are using mongoDB as database which stores object in form of JSON. If you want to convert the JSON response to an array of properties as key value pairs you can refer: Converting JSON Object into Javascript array Or may be change the way you have written your service in nodejs. -V