2017-10-10 47 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问题后出现同样的错误。 –