简体   繁体   English

我正在尝试将我的Azure后端与我的离子角度前端连接起来

[英]I am trying to connect my Azure backend with my ionic angular front end

The table is called sport and I am trying to show the list from the column sport in a drop down list. 该表名为sport,我试图在下拉列表中显示列运动列表。 The error I am getting is Error: [$injector:unpr] Unknown provider: sportServiceProvider <- sportService <- sportCtrl and I cannot see where the mistake is, can anyone help? 我得到的错误是错误:[$ injector:unpr]未知的提供者:sportServiceProvider < - sportService < - sportCtrl我无法看到错误在哪里,任何人都可以帮忙吗?

 <ion-view view-title="Choose Your Team">
  <ion-content      ng-controller="sportCtrl as vm" >


    <label class="item item-input item-select item-positive">
        <div class="input-label">
            Sport
        </div>

        <select>
            <option>
               {{vm.sport}}  
            </option>
           </select>
    </label>                     
    </div>

The service to get the sport is sport.js 获得这项运动的服务是sport.js

 (function () {
 'use strict';

sportService.$inject = ['$http'];

angular
    .module('starter',[azure-mobile-service-module])
    .factory('sportService', sportService);



function sportService($http) {
    var service = {
        getData: getData
    };

    return service;

    function getData() {
        Azureservice.query('sport', {})
    .then (function(sport)
    {
        vm.sport = sport;
    })}
   }
  })();


 angular.module('starter').constant('AzureMobileServiceClient', {
API_URL: "https://",
API_KEY: "",

  });

and the controller is: 控制器是:

 (function () {
'use strict';

sportCtrl.$inject = ['sportService'];

angular
    .module('starter')
    .controller('sportCtrl', sportCtrl);



function sportCtrl(sportService) {
    var vm = this;


    activate();

    function activate() { }

    vm.sportname  = sportService.getData();
}
 })();

It seems that you have initialized repeated angular module named starter , in your sport.js and controller.js scripts. 您似乎已经在sport.jscontroller.js脚本中初始化了名为starter重复角度模块。 In the controller.js script, you have created a new angular application instance which do not have a sportService injected. controller.js脚本中,您创建了一个sportService注入sportService的新角度应用程序实例。

You can define a global variable to the angular instance in sport.js , eg 您可以为sport.js的角度实例定义全局变量,例如

app = angular
    .module('starter',...)

And use this global variable instead of angular.module('starter') , eg 并使用此全局变量而不是angular.module('starter') ,例如

app.controller('sportCtrl', sportCtrl);

Otherwise, you can define a new angular module for your controller and inject in the main angular module. 否则,您可以为控制器定义新的角度模块,并注入主角度模块。 EG 例如

In your controller.js : 在你的controller.js

angular
    .module('starter.ctrl')
    .controller('sportCtrl', sportCtrl);

And in your sport.js : 在你的sport.js

angular
    .module('starter',[azure-mobile-service-module,'starter.ctrl'])

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

相关问题 Angular js 是前端还是后端? - Angular js is front end or backend? 我正在尝试在我的Angular指令中调用一个函数 - I am trying to call a function within my Angular directive 我正在尝试将 Angular 连接到 MongoDB - I am trying to connect Angular to MongoDB 如何使用Asp.net Webapi后端和前端作为Angular在Azure中进行基于角色的授权 - How to do role based authorization in Azure with Asp.net webapi backend and front end as Angular 如何从前端(Angular)向C#.net datetime(webAPI)发送日期? - How can I send a date from my front end (Angular) to C# .net datetime (webAPI)? 无法将角形前端连接到节点后端 - Cannot connect angular front to node backend 我正在使用Angular 1,我试图在用户登录后隐藏我的登录按钮? - I am using Angular 1 and I am trying to ng-hide my login button once a user is logged in? 如何将我的 postgresDB 连接到 Ionic? - How do I connect my postgresDB to Ionic? 我正在尝试使用茉莉花来测试我的角度控制器。 但我收到错误:[$ injector:modulerr] - i am trying to test my angular controller using jasmine. But i am getting Error: [$injector:modulerr] 我如何将我的环形js前端连接到在两个Express服务器上运行的两个套接字不同的连接 - How can i connect my anular js front-end to two socket differernt connections which are running on two express server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM