0
votes

I am new to angular js

code is:

controller.js

var my = angular.module('my',[]);

 my.controller('AppCtrl',['$scope',function ($scope , $http){
    console.log("hello world from controller");

    $http.get('/contactlist');
    person1 ={
        name: 'shubham',
        email:'[email protected]',
        number:'111-222-3333'
    };
    person2 = {
        name: 'ruk',
        email:'[email protected]',
        number:'333-222-3333'
    };
    person3 ={
        name: 'nidhi',
        email:'[email protected]',
        number:'111-222-4444'
    };
    var contactlist = [person1 , person2 , person3];
    $scope.contactlist = contactlist;

}
]);

and server.js

var express = require('express');
var app = express();

app.use(express.static(__dirname + "/public"));

app.get('/contactlist',function(req,res){
    console.log("I recive a get request");

});
app.listen(3000);
console.log("server is running on port 3000");

when i am trying to run this program it gives following error

"Error: $http is undefined @http://localhost:3000/controller/controller.js:6:2 e@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:36:313 Fe/this.$gethttps://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:75:1

1

1 Answers

3
votes

you havent injected properly using array like syntax, it will be found missing in minification

use

my.controller('AppCtrl',['$scope','$http',function ($scope , $http){}])