wwwalkerrun / nativescript-ngx-magic

Magically drop a NativeScript app into your Angular web app and reuse all your code.
MIT License
48 stars 8 forks source link

Including moduleId property in @Component decorator causes 'Module build failed: TypeError: Cannot read property 'getChildAt' of undefined' #10

Closed sebastienratez closed 7 years ago

sebastienratez commented 7 years ago

Hi,

I have the same issue as posted in the angular-cli project: https://github.com/angular/angular-cli/issues/4817 but I realized it may in fact be related to your project since I/we use your @component overwrite:

import { Component } from '@wwwalkerrun/nativescript-ngx-magic';

The problem happened after an update of angular libraries I think. moduleId is required to resolve paths for nativescript views etc. but not by the regular angular web engine. But it didn't use to bother it. Now this simple component crashes with the error explained in the github issue above.

import { Component } from '@wwwalkerrun/nativescript-ngx-magic';
import { OnInit } from '@angular/core';
import { Hero } from './model/Hero';
import { HeroesService } from './services/heroes.service';
@Component({
  moduleId: module.id,
  selector: 'app-root',
  templateUrl: './views/app/app.component.html',
  styleUrls: ['./views/app/app.component.css'],
  providers: [HeroesService]
})
export class AppComponent implements OnInit {
  title = 'app works!';
  heroes: Hero[] = [];

  constructor(private heroesService: HeroesService) {}

  ngOnInit(): void {
      this.heroesService.getHeroes().subscribe(heroesResult => this.heroes = heroesResult);
  }
}