1

I am running hybrid angular 1 app and angular 2 app. I have created a component ActivateAccount. While i am running this application. I am getting console error while downgrading component. Cannot read property 'resolveComponentFactory' of undefined <activate-account class="ng-scope">

I do searched related to this error but i found nothing.

I am referring Using Angular Components from AngularJS Code

app.module.js

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { UpgradeModule, downgradeComponent } from '@angular/upgrade/static';
import { HttpModule }    from '@angular/http';

import { ActivateAccountComponent } from '/thinkshop/widgets2/thinkshopapplication/activateaccount/activateaccount.ts';


@NgModule({
  imports:  [ 
                BrowserModule,
                UpgradeModule ,
                HttpModule
            ],

  declarations: [
                 ActivateAccountComponent
                    ],
    entryComponents: [
                    ActivateAccountComponent
                       ]
})

export class AppModule {
    constructor(private upgrade: UpgradeModule) { }

    ngDoBootstrap() {

    var app= angular.module('IdeolveActivateAccount', ['ngMaterial', 'jlareau.bowser', 'validation.match', 'ngDialog', 'ngMessages']);


        app.controller("ActivateAccountApp", loadActivateAccountApp);
        angular.module('IdeolveActivateAccount').directive('activateAccount', downgradeComponent({ component: ActivateAccountComponent }));

        app.component("ideolveformcomponent",{
            bindings:{
                showideolvelink: '<'
            },
            controller: 'ActivateAccountApp',
            templateUrl: '/thinkshop/widgets2/thinkshopapplication/login/template/landingdisplay.html'
        });

        this.upgrade.bootstrap(document.body, ['IdeolveActivateAccount']);
    }
}

activateaccount.ts

import { Component } from '@angular/core';


@Component({
    selector: 'activate-account',
    template: '<div class="ActivateAccountContainer marginlefttwentypx margintoptwentypx marginrighttwentypx marginbottomtwentypx heighthundredpercent"></div>'     
})

export class ActivateAccountComponent {
    constructor() {}    
}

I think i am missing something. I have checked all my code against tutorial given into above link, But i am getting console error.

7
  • Could you add code of your ActivateAccountService? Commented Oct 10, 2017 at 11:56
  • @JaroslawK. updated the question. Commented Oct 10, 2017 at 12:01
  • why you didn't declare emailId and BASE_URL in your ActivateAccountService? Try email: string; and BASE_URL: string;, before constructor Commented Oct 10, 2017 at 12:32
  • @JaroslawK. Updated my code. But still getting same error. Anything i am doing wrong to downgrade component ? Commented Oct 10, 2017 at 12:41
  • Try add providers: [Http, ActivateAccountService] to providers arrays in app.module and delete from @Component in ActivateAccountComponent Commented Oct 10, 2017 at 12:55

1 Answer 1

1

After a long discussion, the following steps helped:

app.module.ts

providers: [
    {provide: 'CLIENT_ID', useValue: CLIENT_ID},
    {provide: 'APP_NAME', useValue: APP_NAME},
    {provide: 'AUTH_TOKEN', useValue: AUTH_TOKEN},
    {provide: 'CAN_EDIT', useValue: CAN_EDIT},
    //{provide: Http, useValue: Http}, <-- unneccesary, when import HttpModule
    ActivateAccountService // <-- provide service in module, not component
]

activate-account.service.ts

Removing URLSearchParams from constructor, bacause it is not injectable object. Instead of this, you shoul use @angular/router module

Sign up to request clarification or add additional context in comments.

1 Comment

I am getting same error after solving URLSearchParams.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.