技術

[Angular] has no exported member ‘XXXLoginComponent’.

投稿日:

どうも中田です

Angularでコンポーネント名を階層構造にあった名前にしようとコンポーネント名を変えて起動してみるとエラーになっちゃって。。という内容です

コンポーネントはこれで作りました

$ ng g component xxx/login

んで
LoginComponent => XXXLoginComponent
ってクラス名を変更してみると

エラー

ERROR in src/app/xxx/xxx-routing.module.ts(4,10): error TS2305: Module '"/src/app/xxx/login/login.component"' has no exported member 'XXXLoginComponent'.
src/app/xxx/xxx.module.ts(6,10): error TS2305: Module '"/src/app/xxx/login/login.component"' has no exported member 'XXXLoginComponent'.

その時コンポーネントはというと

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})
export class XXXLoginComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

}

どこがおかしいのかなー

どこかなー

解決

コンポーネントのselectorもちゃんと名前を合わせないとですね

@Component({
  selector: 'app-xxx-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})
...
...

ということでした!

-技術

執筆者:


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

関連記事

no image

wordpressでcommon.min.cssが勝手に読み込まれる

こんにちは wordpressで自作テンプレートを作っている時に、見た目が崩れた …

[Angular] @NgModuleをざっくりと

どうも中田です。 最近社内でAngularの波が起こってるので そのビッグウェー …

no image

[Angular]リアクティブフォームでバリデーション名を動的に出し分ける。

Angularのリアクティブフォームのカスタムバリデーションで、動的にエラー名を …

[AWS S3] This XML file does not appear to have any style information associated with it. The document tree is shown below.

はじめまして。田中です。 AWSを触りはじめてから1ヶ月ちょっと。七転び八起きな …

セレクトボックスにfont-awesomeのアイコンを使うときは注意が必要。

セレクトボックスの中にfont-awesomeのアイコンを表示したい。 そんなと …