netdjw
netdjw

Reputation: 5997

No template specified for component in Angular 8/9

I get this error message after I updated from Angular 8 to Angular 9:

Error: error TS100: No template specified for component AddressTypeCreateEditComponent

In Angular 8 got this error if I tried to build in production mode, but it wasn't neccessary in this case right now. But now I updated and the update's migration process get this error again.

Here is the AddressTypeCreateEditComponent:

import { Component, OnInit } from '@angular/core';
import { AbstractCreateEditComponent } from 'src/app/components/_absrtact/create-edit/abstract-create-edit.component';
import { AddressTypeInterface } from 'src/app/models/address/type/address-type.interface';
import { AddressType } from 'src/app/models/address/type/address-type.model';
// this is a .ts file
import template from 'src/app/components/_absrtact/create-edit/abstract-create-edit.component.html';

@Component({
  selector: 'app-address-type-create-edit',
  template: template as string,
})
export class AddressTypeCreateEditComponent extends
    AbstractCreateEditComponent<AddressTypeInterface>
    implements OnInit {

  constructor() {
    super(AddressType);
  }

}

Here is the abstract-create-edit.component.html.ts:

export default `<div class="container-fluid">...</div>`;

Upvotes: 0

Views: 1767

Answers (1)

Ghonima
Ghonima

Reputation: 3082

Create a address-type-create-edit.html and put the html inside of it then change

@Component({
  selector: 'app-address-type-create-edit',
  template: template as string,
})

to

@Component({
  selector: 'app-address-type-create-edit',
  templateUrl: './address-type-create-edit.html',
})

Upvotes: 4

Related Questions