2017-10-10 48 views
1

我正在運行混合角1應用程序和角2應用程序。我創建了一個組件ActivateAccount。當我運行這個應用程序。 我收到控制檯錯誤,同時降級組件。 Cannot read property 'resolveComponentFactory' of undefined <activate-account class="ng-scope">獲取錯誤,同時降級角2組件

我搜索了與此錯誤有關的信息,但是我什麼也沒找到。

我指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() {}  
} 

我覺得我失去了一些東西。我已經檢查了所有我的代碼對上述鏈接給出的教程,但我得到控制檯錯誤。

+0

您可以添加ActivateAccountService的代碼嗎? –

+0

@JaroslawK。更新了問題。 –

+0

爲什麼你沒有在你的ActivateAccountService中聲明'emailId'和'BASE_URL'?在構造函數 –

回答

1

discussion後,下面的步驟幫助:

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 
] 

激活-account.service.ts

從刪除URLSearchParams構造函數,因爲它不是可注入的對象。取而代之,您可以使用@angular/router模塊

+0

解決URLSearchParams問題後出現同樣的錯誤。 –