angular始めました。
動かすために調べたことをメモしています。
1095 views
次のメッセージが表示され、コンパイルが通らない。
*
This likely means that the library (@angular/forms) which declares FormControl has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
*
app.modules.tsでFormControlをインポートしている場合。
angularのバージョンアップが原因と思われる。ちょっと前までは大丈夫な書き方だった。
しかし、★の部分に示すようにFormControlをインポートすると、コンパイルエラーになる。
import { FormControl, ReactiveFormsModule } from '@angular/forms'; ★
@NgModule({
  declarations: [
    AppComponent,
    BlasAuthComponent,
  ],
  imports: [
    BrowserModule,
    ReactiveFormsModule,
    FormControl, ★
  ],
  providers: [],
  bootstrap: [BlasAuthComponent]
})
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ReactiveFormsModule } from '@angular/forms';★
import { AppComponent } from './app.component';
import { BlasAuthComponent } from './blas-auth/blas-auth.component';
@NgModule({
  declarations: [
    AppComponent,
    BlasAuthComponent,
  ],
  imports: [
    BrowserModule,
    ReactiveFormsModule, ★
  ],
  providers: [],
  bootstrap: [BlasAuthComponent]
})
export class AppModule { }
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms'; ★
@Component({
  selector: 'app-blas-auth',
  templateUrl: './blas-auth.component.html',
  styleUrls: ['./blas-auth.component.css']
})
export class BlasAuthComponent implements OnInit {
  message:string="";
  loginForm: FormGroup = new FormGroup({
    userName: new FormControl(''),
    password: new FormControl('')});
  constructor() { }
  ngOnInit(): void {
  }
  onSubmit() {
    let result = this.loginForm?.value;
    this.message = JSON.stringify(result);
    console.log(this.message);
  }
}
これで、FormControl,FormGroupを使用できる。
イイねと思った方は左上の★ボタンを押してください。
Page 30 of 38.
1.angular flex layoutについて.docx
        
         
                        
                    
すぺぺぺ
                    
                    本サイトの作成者。
プログラムは趣味と勉強を兼ねて、のんびり本サイトを作っています。
フレームワークはdjango。
ChatGPTで自動プログラム作成に取り組み中。
                    
                
https://www.osumoi-stdio.com/novel/