0

I know almost same kind of question is answered in couple of other posts but I'm getting "Unknown provider" error on calling service written in different file then callee Controller function. Could some one please help me to know what am I doing wrong? Here is my code

Controller.js

var mainApp = angular.module("mainApp", []);

mainApp.controller("PromoList", ['$scope', '$http', 'modelSerivce', function ($scope, $http, modelSerivce){
var serviceURL = modelSerivce.serviceURL();
console.log("from promolist controller: "+ serviceURL);}]);

Service.js

angular.module('mainApp').service('modelSerivce', function(){       
this.serviceURL = function()
{
    var serviceURL = “cofig.xml”;
    return serviceURL;
};});
2
  • 1
    Are you including Service.js in your HTML? Commented May 9, 2014 at 15:46
  • 1
    And if you are including Service.js is it included AFTER Controller.js? This ensures that you have created your module, mainApp, before referencing it. Commented May 9, 2014 at 15:49

1 Answer 1

2

Did you reference Service.js in your .html file?

Sign up to request clarification or add additional context in comments.

2 Comments

Oh yeah I missed referencing Services.js in html and that worked!! Thanks a ton !!!
Anytime! Glad I helped :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.