Swetha

Swetha

  • NA
  • 196
  • 25.6k

Error: [$injector:undef] in angualrjs

Mar 25 2019 4:16 AM
Hi ,
 
I created a service and injected that into a controller.But getting error like "Error: [$injector:undef] http://errors.angularjs.org/1.6.9/$injector/undef?p0=addlabtestsvc"
what would be the error?
 
Please respond ASAP.
 
controller:
  1. var app=angular.module('AddlabTest',[]);  
  2. app.controller("AddlabTestcontroller",['$scope','addlabtestsvc',function($scope,addlabtesttsvc)  
  3. {  
  4. $scope.msg="Angularexample";  
  5. $scope.SaveToLabtest=function()  
  6. {  
  7. alert("");  
  8. addlabtestsvc.addItem();  
  9. }  
  10. }]);  
Service:
  1. "use strict";  
  2. (function()  
  3. {  
  4. angular.module('AddlabTest')  
  5. .factory('addlabtestsvc',function()  
  6. {  
  7. var addItem = function()  
  8. {  
  9. alert("message");  
  10. };  
  11. });  
  12. })();

Answers (1)