AngularJs中没有函数错误

拉尼·拉德克利夫(Rani Radcliff)

每当我尝试向控制器和服务添加“新”功能时,都会出现此错误:错误:[$ injector:unpr]未知提供程序:companyServiceProvider <-companyService <-CompanyController

我玩了几次函数,然后奇迹般地开始工作(我最后一次所做的就是更改函数的名称)。必须有一种防止这种情况发生的方法,但是对于我的一生,我无法弄清楚。

这是我的控制器代码的片段:

myApp.controller("CompanyController",  function($scope, $timeout, companyService){

    $scope.SelectedCompanyId = '';
    $scope.form = {};
    $scope.lastState = true;
    pass = 0;
    $scope.addedStates = [];
    getCompanies();
    function getCompanies() {
        companyService.getCompanies()
            .success(function (data) {
                $scope.companies = data;
            })
         .error(function (error) {
             $scope.status = 'Unable to load customer data: ' + error.message;
         });
    };

    getModules();
    function getModules() {
        companyService.getModules()
        .success(function (data) {
            $scope.modules = data;
        })
        .error(function (error) {
            $scope.status = 'Unable to load Dashboard Modules: ' + error.message;
        });
    };
        getModuleColors();
    function getModuleColors() {
        companyService.getModuleColors()
        .success(function (data) {
            $scope.colors = data;
        })
        .error(function (error) {
            $scope.status = 'Unable to load Dashboard Modules: ' + error.message;
        });
    };

这是我的服务的摘要:

angular.module('dashboardManagement')
.service('companyService'(), [
'$http', function ($http) {
    //this.selectedCompanyId = null;
    this.getCompanies = function () {
        return $http.get('/Home/GetAllCompanies');
    };
    this.getModules = function () {
        return $http.get('/Home/GetDashboardModules');
    };

    this.getModuleColors = function () {
        return $http.get('/Home/GetModuleColors');
    };
    this.getCurrentModules = function (companyId) {
        //this.selectedCompanyId = companyId;
        return $http.get('/Home/GetCurrentModules?companyId=' + companyId);

    };

现在引发错误的函数是“ getModuleColors”函数,因为它是最后添加的函数。

其他功能工作正常。有人可以告诉我这是怎么回事吗?

任何帮助都将不胜感激。

乔奥·波罗

这是您的代码正常工作:

https://jsfiddle.net/afv4t8h2/1/

您需要将要服务的脚本放在控制器的脚本之前,并且在代码上有一个小错误:

<li ng-repeat="region in serviceRegions">{{region.}}</li>

这是一个不间断的角度表达式...正确为{{region}}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

没有出现函数错误

来自分类Dev

没有出现函数错误

来自分类Dev

没有匹配的函数错误C ++构造函数

来自分类Dev

第二次单击时,jQuery中没有函数错误

来自分类Dev

没有默认构造函数时,没有默认构造函数错误

来自分类Dev

“错误:没有匹配的函数可调用”构造函数错误

来自分类Dev

angularjs对象不是函数错误

来自分类Dev

默认构造函数错误,没有用于调用的匹配函数

来自分类Dev

将2D向量传递给使用对象的函数,没有匹配的函数错误

来自分类Dev

服务中的AngularJS函数在路由更改后抛出“不是函数错误”?

来自分类Dev

Angular2类的构造函数错误:没有Number的提供程序

来自分类Dev

Lambda表达式内没有匹配的成员函数错误?

来自分类Dev

对指针列表进行排序C ++-没有匹配的函数错误

来自分类Dev

PostgreSQL函数错误ERROR:查询没有结果数据的目的地

来自分类Dev

地图支持上没有空的构造函数错误

来自分类Dev

Jqgrid没有渲染并且在调试时显示未定义不是函数错误

来自分类Dev

Angular2类构造函数错误:没有Number的提供程序

来自分类Dev

具有函数错误的枚举

来自分类Dev

php - 带有 case + if 的函数错误

来自分类Dev

$ event.stopPropogation不是Angularjs单元测试中的函数错误

来自分类Dev

未捕获的TypeError:fn不是AngularJS网页中的函数错误

来自分类Dev

函数错误C中的静态数组

来自分类Dev

效果包中的effect()函数错误

来自分类Dev

Netezza中的SQLEXT函数错误

来自分类Dev

在phpmyadmin中创建函数错误

来自分类Dev

Matlab中的嵌套函数错误

来自分类Dev

捕获函数中的参数错误?

来自分类Dev

Netshel Paypal中的getCheckout函数错误

来自分类Dev

函数错误C中的静态数组

Related 相关文章

热门标签

归档