Шаблон разбора ошибок: неожиданный закрывающий тег app-post-list - PullRequest
0 голосов
/ 01 апреля 2020

Ошибка при попытке вывести свой пост в angular. помогите решить эту проблему ...

сообщение об ошибке

Шаблон синтаксического анализа ошибок: неожиданный закрывающий тег "app-post-list".

мой код post-list.component.ts

import { Component } from "@angular/core";

@Component({
selector: 'aap-post-list',
templateUrl: './post-list.component.html'
})

export class PostListComponent {}

мой post-list.component. html

<mat-accordion>
   <mat-expansion-panel>
    <mat-expansion-panel-header>
      The expansion title!
    </mat-expansion-panel-header>
    <p>I'm in an expansion panel!</p>
   </mat-expansion-panel>
</mat-accordion>

app.component. html код

<app-header></app-header>
<main>
  <app-post-create></app-post-create>
  <aap-post-list></app-post-list>
</main>

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatInputModule} from '@angular/material/input';
import { MatCardModule} from '@angular/material/card';
import { MatButtonModule } from '@angular/material/button';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatExpansionModule } from '@angular/material/expansion';
import { AppComponent } from './app.component';
import {PostCreateComponent} from './posts/post-create/post-create.component';
import { HeaderComponent } from './header/header.component';
import { PostListComponent } from './posts/post-list/post-list.component';
import { from } from 'rxjs';

@NgModule({
declarations: [
AppComponent,
PostCreateComponent,
HeaderComponent,
PostListComponent
],
imports: [
BrowserModule,
FormsModule,
BrowserAnimationsModule,
MatInputModule,
MatCardModule,
MatButtonModule,
MatToolbarModule,
MatExpansionModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

app.component.spe c .ts

import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { PostListComponent } from './posts/post-list/post-list.component';

describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
  declarations: [
    AppComponent,
    PostListComponent
  ],
}).compileComponents();
}));

it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});

it(`should have as title 'mean-learning'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('mean-learning');
});

it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(compiled.querySelector('.content span').textContent).toContain('mean-learning app is running!');
});
});

enter image description here

Пожалуйста, дайте мне знать, где я ошибаюсь и как я решаю эту проблему.

1 Ответ

0 голосов
/ 01 апреля 2020

Привет, вы выполнили опечатку в номере строки 4 измените <aap-post-list> на <app-post-list> проблема решена.

app.component. html код

<app-header></app-header>
<main>
  <app-post-create></app-post-create>
  <aap-post-list></app-post-list>
</main>

Обновлено

Вы изменили <aap-post-list> to <app-post-list>, теперь go вернулось к

post-list.component.ts

теперь измените селектор на

import {Component} с "@ angular / core";

@Component({
selector: 'aap-post-list',
templateUrl: './post-list.component.html'
})

export class PostListComponent {}

на

import {Component} из "@ angular / core";

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

export class PostListComponent {}

теперь должно работать нормально

...