Loïc Bar
Loïc Bar

Reputation: 1

Template content doesn't show up after upgrading to Angular 6.1

I'm getting as a result of my app.component the name of the template file : client/imports/app/app.component.html

Image screenshot

Instead of processing my template with its content.

Here's my component code:

import { Component, NgZone } from '@angular/core';
import { Location } from '@angular/common';
import { Router } from '@angular/router';
import template from './app.component.html';

@Component({
  selector: 'app-root',
  template,
})
export class AppComponent {
   user: Meteor.User;

   constructor(private router: Router, zone: NgZone, location:Location) {
    Tracker.autorun(() => {
      if (Meteor.user())
      {
         zone.run(() => {
            this.user = Meteor.user();
         });
      }
      else
      {
        this.user = undefined;
      }
    });
  }

 isMenuActive(value)
 {
    return location.pathname.indexOf(value) !== -1;
 }

 isHome()
 {
    return location.pathname == ""
 }
}

Any idea of why it doesn't seem to work anymore?

Thanks,

Upvotes: 0

Views: 54

Answers (2)

Paul Cochrane
Paul Cochrane

Reputation: 399

The usage of the angular meteor compiler package changed a few versions of angular ago. A place to look for info is in the compiler repository itself. There is an example app.

https://github.com/Urigo/angular-meteor/tree/master/examples/MeteorCLI/all-in-one

Basically, you don’t import the template but reference it via templateurl

E.g

@Component({
  selector: 'app',
  templateUrl: 'app.component.html'
})

Upvotes: 1

billyjov
billyjov

Reputation: 2970

Use the Component decorator like describe in the angular component-metadata documentation.

Write this import template from './app.component.html'; will be wrong because your template html as no member called template.

You may rewrite your decorator instead like this :

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})

Upvotes: 0

Related Questions