Angular2 - Using a component from another application

I am trying to use a component in my application from another application. My projects are in the same folder, so I thought it would work, but I get the exception "I can not find the module." Is there any way to do this? or another way to achieve this?

What i have done so far:

import { Component, OnInit } from '@angular/core';
import { OverviewPaginationComponent } from './../../../../overview/src/app/overview-pagination/overview-pagination.component.ts';

@Component({
  moduleId: module.id,
  selector: 'combi',
  template: `
 <overview-pagination><overview-pagination>

`,
  styleUrls: ['combi.component.css'],
  providers: [],
  directives: [OverviewPaginationComponent]
})
export class CombiComponent implements OnInit {

  constructor() {}

  ngOnInit() {
  }

}

And defined in systemConfig:

const barrels: string[] = [
  // Angular specific barrels.
  '@angular/core',
  '@angular/common',
  '@angular/compiler',
  '@angular/forms',
  '@angular/http',
  '@angular/router',
  '@angular/platform-browser',
  '@angular/platform-browser-dynamic',
  '@angular/router-deprecated',

  // Thirdparty barrels.
  'rxjs',

  // App specific barrels.
  'app',
  'app/shared',
  'app/combi',
  '../../overview/src/app/overview-pagination',
  /** @cli-barrel */
];
+4
source share
1 answer

You must add the component that you are trying to use in the parent module of this “function”, where you intend to use the component. For example, assuming this module is the parent module in which you are trying to use OverviewPaginationComponent:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { OverviewPaginationComponent } from 'path';


@NgModule({
  declarations: [
    AppComponent,
    OverviewPaginationComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
0

All Articles