Это мой < strong> auth.component.html , что я хотел бы загрузить
Код: Выделить всё
Username
Password
Submit
Код: Выделить всё
import { Component, OnInit, Inject } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
import { ApiService } from '../api.service';
@Component({
selector: 'app-auth',
standalone: false,
templateUrl: './auth.component.html',
styleUrl: './auth.component.css'
})
export class AuthComponent implements OnInit{
authForm: any = new FormGroup({
username: new FormControl(''),
password: new FormControl(''),
});
constructor(
@Inject('url') private apiService: ApiService
) { }
ngOnInit(): void {
}
saveForm() {
this.apiService.loginUser(this.authForm.value).subscribe(
(result: any) => console.log(result),
(error: any) => console.log(error)
);
}
}
Код: Выделить всё
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Routes, RouterModule } from '@angular/router';
import { ReactiveFormsModule } from '@angular/forms';
import { AuthComponent } from './auth.component';
import { AppComponent } from '../app.component';
const routes: Routes = [
{path: 'auth', component: AuthComponent},
];
@NgModule({
declarations: [
AppComponent,
AuthComponent,
],
imports: [
CommonModule,
RouterModule.forChild(routes),
ReactiveFormsModule
],
exports: [
RouterModule,
],
})
export class AuthModule { }
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { Routes, RouterModule } from '@angular/router';
import { HttpClientModule } from '@angular/common/http';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { ReactiveFormsModule } from '@angular/forms';
import { AuthModule } from './auth/auth.module';
import { MainModule } from './main/main.module';
import { AppComponent } from './app.component';
import { AuthComponent } from './auth/auth.component';
const routes: Routes = [
{path: '', pathMatch: 'full', redirectTo: 'auth'},
];
@NgModule({
declarations: [],
imports: [
FontAwesomeModule,
BrowserModule,
AuthModule,
MainModule,
HttpClientModule,
RouterModule.forRoot(routes),
ReactiveFormsModule,
],
exports: [
RouterModule,
],
providers: [],
bootstrap: [AppComponent, AuthComponent]
})
export class AppModule { }
< /code>
Нет ошибок, и моя другая HTML -страница работает нормально. При необходимости я могу создать проект GitHub, чтобы показать вам полный код, но я надеюсь, что этого достаточно
Подробнее здесь: https://stackoverflow.com/questions/794 ... ror-either