3

我有一项服务,我想将它传递给 Angular 1.5 中的组件。我没有使用 Gulp 或 TypeScript。

这是服务:

(function() {'use strict';
angular.module('flavorApplication')
  .component('app', {
  	templateUrl: "app/app.component.html",
    controllerAs: "vm",
  	controller: function AppController() {

这是组件:

(function() {'use strict';
angular.module('flavorApplication')
  .component('app', {
  	templateUrl: "app/app.component.html",
    controllerAs: "vm",
  	controller: function AppController('DataService')

这没有用。我也试过:

controller: ['DataService', function AppController('DataService')

这也没有奏效。请记住,我是 Angular 的新手,只是让我的饲料在我身下。谢谢您的帮助!

4

1 回答 1

2

您不需要单引号。

controller: function AppController(DataService)
于 2016-06-24T15:44:32.970 回答