我知道在其他几个帖子中几乎回答了同样的问题但是我在调用不同文件中写入的服务时出现“未知提供程序”错误,然后是被调用者控制器函数。有人可以帮助我知道我做错了什么吗?这是我的代码
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;
};});
答案 0 :(得分:2)
您是否在.html文件中引用了Service.js
?