Hello,

I had all my dependency injection working in Alpha 45, but now when I try 
and do the same thing in beta 0, I am getting "*EXCEPTION: Cannot resolve 
all parameters for AppComponent(?, ?). Make sure they all have valid type 
or annotations.*" I am wondering if it is a usage error by me, or if 
something has changed that I don't see in the change notes. I am trying to 
inject the app state (a largely terrible name) into another service. I want 
the service to know when the user is logged in and the user's details. For 
whatever reason, the app.component.js file doesn't seem to have the 
coreService or appState service defined. Any help would be really 
appreciate.

*boot.ts*

import {bootstrap}    from 'angular2/platform/browser';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/common';
import {provide} from 'angular2/core';
import {AppState} from './services/appState';
import {CoreService} from './services/core.service';
import {AppComponent} from './app.component';

let coreServiceFactory = (app: AppState) => {
return new CoreService(app);
}
let coreServiceDefinition = {
useFactory: coreServiceFactory,
deps: [AppState]
}
let coreServiceProvider = provide(CoreService, coreServiceDefinition);

bootstrap(AppComponent, [ROUTER_PROVIDERS, CORE_DIRECTIVES, 
FORM_DIRECTIVES, coreServiceProvider, AppState]);

boot.js
System.register(['angular2/platform/browser', 'angular2/router', 
'angular2/common', 'angular2/core', './services/appState', 
'./services/core.service', './app.component'], function(exports_1) {
    var browser_1, router_1, common_1, core_1, appState_1, core_service_1, 
app_component_1;
    var coreServiceFactory, coreServiceDefinition, coreServiceProvider;
    return {
        setters:[
            function (browser_1_1) {
                browser_1 = browser_1_1;
            },
            function (router_1_1) {
                router_1 = router_1_1;
            },
            function (common_1_1) {
                common_1 = common_1_1;
            },
            function (core_1_1) {
                core_1 = core_1_1;
            },
            function (appState_1_1) {
                appState_1 = appState_1_1;
            },
            function (core_service_1_1) {
                core_service_1 = core_service_1_1;
            },
            function (app_component_1_1) {
                app_component_1 = app_component_1_1;
            }],
        execute: function() {
            coreServiceFactory = function (app) {
                return new core_service_1.CoreService(app);
            };
            coreServiceDefinition = {
                useFactory: coreServiceFactory,
                deps: [appState_1.AppState]
            };
            coreServiceProvider = 
core_1.provide(core_service_1.CoreService, coreServiceDefinition);
            browser_1.bootstrap(app_component_1.AppComponent, 
[router_1.ROUTER_PROVIDERS, common_1.CORE_DIRECTIVES, 
common_1.FORM_DIRECTIVES, coreServiceProvider, appState_1.AppState]);
        }
    }
});
//# sourceMappingURL=boot.js.map

*app.component.ts*

import {Component, Inject} from 'angular2/core';
import {ROUTER_DIRECTIVES, RouteConfig, Router, ROUTER_PROVIDERS, Location} 
from 'angular2/router';
import {AppState} from './services/appState';
import {CoreService} from './services/core.service';
import {GalleryComponent} from './components/gallery/gallery.component';
import {SearchComponent} from './components/search/search.component';


@Component({
    selector: 'my-app',
    templateUrl: 'app/home.html',
directives: [ROUTER_DIRECTIVES]
})

@RouteConfig([
{ path: '/', name: 'Gallery', component: GalleryComponent },
{ path: '/search', name: 'Search', component: SearchComponent }
])

export class AppComponent {

constructor(private app: AppState, private service: CoreService) {
}

}

*app.component.js*

System.register(['angular2/core', 'angular2/router', 
'./components/gallery/gallery.component', 
'./components/search/search.component'], function(exports_1) {
    var __decorate = (this && this.__decorate) || function (decorators, 
target, key, desc) {
        var c = arguments.length, r = c < 3 ? target : desc === null ? desc 
= Object.getOwnPropertyDescriptor(target, key) : desc, d;
        if (typeof Reflect === "object" && typeof Reflect.decorate === 
"function") r = Reflect.decorate(decorators, target, key, desc);
        else for (var i = decorators.length - 1; i >= 0; i--) if (d = 
decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, 
key)) || r;
        return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    var core_1, router_1, gallery_component_1, search_component_1;
    var AppComponent;
    return {
        setters:[
            function (core_1_1) {
                core_1 = core_1_1;
            },
            function (router_1_1) {
                router_1 = router_1_1;
            },
            function (gallery_component_1_1) {
                gallery_component_1 = gallery_component_1_1;
            },
            function (search_component_1_1) {
                search_component_1 = search_component_1_1;
            }],
        execute: function() {
            AppComponent = (function () {
                function AppComponent(app, service) {
                    this.app = app;
                    this.service = service;
                }
                AppComponent = __decorate([
                    core_1.Component({
                        selector: 'my-app',
                        templateUrl: 'app/home.html',
                        directives: [router_1.ROUTER_DIRECTIVES]
                    }),
                    router_1.RouteConfig([
                        { path: '/', name: 'Gallery', component: 
gallery_component_1.GalleryComponent },
                        { path: '/search', name: 'Search', component: 
search_component_1.SearchComponent }
                    ])
                ], AppComponent);
                return AppComponent;
            })();
            exports_1("AppComponent", AppComponent);
        }
    }
});
//# sourceMappingURL=app.component.js.map

Cheers!

-- 
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 https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to