我知道在其他几篇文章中也回答了几乎相同的问题,但是在调用以不同文件编写的服务时出现“未知提供程序”错误,然后是被调用方控制器函数。有人可以帮我知道我在做什么错吗?这是我的代码

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;
};});

最佳答案

您是否在.html文件中引用了Service.js

10-07 17:38