3

I have a service that I want to pass into a Component in Angular 1.5. I'm not using Gulp or TypeScript.

This is the service:

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

This is the Component:

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

This didn't work. I also tried:

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

This also didn't work. Keep in mind I'm new to angular and just getting my feed under me. Thank you for your help!

2
  • You don't need the single quotes. controller: function AppController(DataService) Commented Jun 24, 2016 at 15:40
  • @Lex can you reply that as the answer? That was it. I upvoted and accidentally deleted the vote Commented Jun 24, 2016 at 15:43

1 Answer 1

2

You don't need the single quotes.

controller: function AppController(DataService)
Sign up to request clarification or add additional context in comments.

1 Comment

that's the beauty of removing array syntax , not more confusion :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.