Hi,

I too, can't find how to inject Http (or $http?) service. Some examples 
mentioned adding an import of "angular2/di.d.ts" but I could not find it 
with "tsd" or in definitely-typed repo.
Please help.

Thanks.

On Thursday, July 30, 2015 at 12:21:48 AM UTC+3, Pete Moss wrote:
>
> I am using Angular2 2.0.0-alpha.32  and not having any luck injecting a 
> service. I am simply following along in the Step by Step Guide:
> https://angular.io/docs/js/latest/guide/displaying-data.html
> but the example they show does not seem to work for me. Worked fine until 
> I attempted to refactor the hard-coded names from the MyListComponent ctor 
> into a FriendsService service. Now, nothing shows up, and the constructor 
> of both the FriendsService and MyListComponent never even get called. I saw 
> somewhere where appInjector was going away, but I tried that and 
> componentServices, viewInjector and hostInjector. Nothing worked for me. 
> Should be something simple, but not getting any love. Can someone help me?
>
> /// <reference path="typings/angular2/angular2.d.ts" />
>
> import {Component, View, bootstrap, NgFor} from 'angular2/angular2';
>
>
> class FriendsService
> {
>     names: Array<string>;
>
>     constructor()
>     {
>         this.names = ["Amit", "Dusan", "Kristin", "Mike"];
>     }
> }
>
> @Component({
>     selector: 'my-list',
>     appInjector: [FriendsService]
> })
> @View({
>     templateUrl: 'ShowList.html',
>     directives: [NgFor]
> })
> class MyListComponent
> {
>     name: string;
>     names: Array<string>;
>
>     constructor(friendsService:FriendsService)
>     {
>         this.name = "Pete";
>         this.names = friendsService.names;
>     }
> }
>
> bootstrap(MyListComponent, [FriendsService]);
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to