Error when trying to inject service in angular controller - Error: [$injector:unpr] Unknown provider: RRS feed

  • Question

  • User2058796294 posted


    I am new to `AngularJs`.
    I am trying to consume Web API using AngularJs but getting struck angular side which is hard for me to figure out.

    I created HTML, controller and service. Everything seems ok to me but when running the app i get the injection error.


    <html >
    <title>Motors </title>
    <script src="/Scripts/angular.js"></script>
    <script src="/Scripts/angular-route.js"></script>
    <script src="/View/motorController.js"></script>
    <body ng-app="myApp" ng-controller="motorController">
    <table class="table">
    <tr ng-repeat="m in motors">

    **AngularJs controller**

    var module = angular.module('myApp', [])
    .controller('motorController', ['$scope', '$motorService',function ($scope, motorService) {
    function getMotors() {
    .success(function (motors) {
    $scope.motors = motors;
    .error(function (error) {
    $scope.status = 'Unable to load motor data: ' + error.message;

    **angular service**

    motorApp.factory('motorService', function ($http) {
    var urlBase = 'http://localhost:40738/api';
    var motorService = {};
    motorService.GetAllMotors = function () {
    return $http.get(urlBase + '/GetAllMotors');
    return motorService;

    Error i am getting on chrmoe browser console

    Error: [$injector:unpr] Unknown provider: $motorServiceProvider <- $motorService <- motorController

    Saturday, September 19, 2015 2:35 AM


  • User61956409 posted

    Hi MuhammadSohail,

    Error: [$injector:unpr] Unknown provider: $motorServiceProvider <- $motorService <- motorController

    The following link explained about this issue, please refer to it.


    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 21, 2015 2:02 AM