angularjs - ERROR:- $http is undefined in angular in conroller.js file -
i new angular js
code is:
controller.js
var = angular.module('my',[]); my.controller('appctrl',['$scope',function ($scope , $http){ console.log("hello world controller"); $http.get('/contactlist'); person1 ={ name: 'shubham', email:'sbatra@gmail.com', number:'111-222-3333' }; person2 = { name: 'ruk', email:'r.rani@gmail.com', number:'333-222-3333' }; person3 ={ name: 'nidhi', email:'nidhi459@gmail.com', 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 request"); }); app.listen(3000); console.log("server running on port 3000"); when trying run program gives following error
"error: $http 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
you havent injected using array syntax, found missing in minification
use
my.controller('appctrl',['$scope','$http',function ($scope , $http){}])
Comments
Post a Comment