简体   繁体   English

角依赖性不加载

[英]Angular dependancy not loading

The title may be deceiving, but I do not know what is going on here. 标题可能在欺骗,但我不知道这里发生了什么。 Here is my controller setup: 这是我的控制器设置:

angular.module('myApp.controllers', [])
.controller('AboutCtrl', ['$scope', 'About', function ($scope, About) {
    $scope.about = About.query();
}])

I am getting the angular error: http://docs.angularjs.org/error/ $injector/unpr?p0=AboutProvider%20%3C-%20About. 我收到了角度错误: http ://docs.angularjs.org/error/ $ injector / unpr?p0 = AboutProvider%20%3C-%20About。

I have this module: 我有这个模块:

angular.module('myApp.restServices', ['ngResource'])
    .factory('About', ['$resource',
        function ($resource) {
            return $resource(service.about, {});
        }])

What am I missing? 我想念什么?

The answer was pretty simple, when declaring the myApp module, I need to inject the dependancy: 答案非常简单,在声明myApp模块时,我需要注入依赖项:

angular.module('myApp', [
    'ngTouch',
    'ngRoute',
    'ngAnimate',
    'myApp.controllers',
    'myApp. restServices'
]).

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM