AngularJS:引发未知提供程序错误

时间:2015-11-25 00:46:02

标签: javascript angularjs

我查看了这个错误的许多线程,但是按照其中2个的说明,它仍然会抛出相同的错误,这是我的服务:

           Dictionary<string, string> Data = new Dictionary<string, string>(){
                {"Ancestor", "Arthur"},
                {"Successor", "Fred"}
             };
​

这是我的控制器:

angular.module('sccateringApp')
  .service('httpcalls', function ($scope, $http) {
      var BackEndBaseURL = "methods/server.php";
      return {
          ..
      }
  });

我无法确定问题所在,因为我已将服务本身作为控制器的依赖项。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:1)

更新:Phil是对的,真正的提供程序错误来自对import QtQuick 2.5 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.1 ApplicationWindow { id: window visible: true width: 640 height: 480 minimumWidth: 50 title: qsTr("Hello World") RowLayout { id: ntoolbarline anchors.fill: parent Rectangle { color: "red" Layout.fillWidth: true Layout.preferredWidth: text.implicitWidth + 40 Layout.preferredHeight: 25 Layout.minimumWidth: 25 Layout.maximumWidth: text.implicitWidth + 40 Text { id: text anchors.fill: parent text: "Foooooooo" elide: Text.ElideRight verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter renderType: Text.NativeRendering } } Rectangle { color: "red" Layout.fillWidth: true Layout.preferredWidth: text.implicitWidth + 40 Layout.preferredHeight: 25 Layout.minimumWidth: 25 Layout.maximumWidth: text.implicitWidth + 40 Text { id: text2 anchors.fill: parent text: "Baaaaaaaar" elide: Text.ElideRight verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter renderType: Text.NativeRendering } } Item { id: spacer Layout.fillWidth: true } } } 的依赖,当他发布时会归功于他。

看起来您正在创建工厂,而不是服务。

您不需要从服务中返回任何内容,而是在$scope中声明内容(这是一个原型实例,就像一个类)。

this

否则,只需将sccateringApp.service('httpcalls', function ($scope, $http) { var BackEndBaseURL = "methods/server.php"; this.someMethod = function() { ... } this.someProperty = ... }); 替换为module.service

相关问题