«полный календарь» не является известным элементом: - PullRequest
0 голосов
/ 09 апреля 2020

Эй, я новичок в Angular ... Пока что я хочу попробовать полный календарь. Я пытаюсь запустить модуль раньше, и он работает. Однако сегодня я создал новый проект и просто выполнил шаги, описанные в angular do c. Более того, я прошел все шаги в fullcalendar do c, но он все еще не работает.

это ошибка, которую я получаю:

ERROR in src/app/app.component.html:1:1 - error NG8001: 'full-calendar' is not a known element:
1. If 'full-calendar' is an Angular component, then verify that it is part of this module.
2. If 'full-calendar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

1 <full-calendar defaultView="dayGridMonth" [plugins]="calendarPlugins"></full-calendar>

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {FullCalendarModule} from '@fullcalendar/angular';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FullCalendarModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.ts

import { Component } from '@angular/core';
import dayGridPlugin from '@fullcalendar/daygrid';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'nachweis-frontend';
  calendarPlugins = [dayGridPlugin];
}

app.component. html

<full-calendar [plugins] = "calendarPlugins"></full-calendar>

Вот и мой angular json. Я не сделал никаких изменений здесь:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "nachweis-frontend": {
      "projectType": "application",
      "schematics": {},
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/nachweis-frontend",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": true,
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb",
                  "maximumError": "10kb"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "nachweis-frontend:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "nachweis-frontend:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "nachweis-frontend:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        },
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "nachweis-frontend:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "nachweis-frontend:serve:production"
            }
          }
        }
      }
    }
  },
  "defaultProject": "nachweis-frontend",
  "cli": {
    "analytics": false
  }
}

Ответы [ 2 ]

1 голос
/ 09 апреля 2020

После просмотра вашего кода GitHub, и я знаю, что он был в файле, который вы опубликовали в своем сообщении, но по какой-то причине этого не хватало в app.module.ts в вашем GitHub:

import { FullCalendarModule } from '@fullcalendar/angular';

и

imports: [
    BrowserModule,
    FullCalendarModule
],

Я проверил его на своей машине, поэтому, если у вас установлены все пакеты npm в вашем package.json, ваш код теперь должен работать

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

возможно, попробуйте с этим .. (как говорит c в: https://fullcalendar.io/docs/angular)

npm install --save @fullcalendar/angular @fullcalendar/core @fullcalendar/daygrid

2-) после этого импортируйте модуль в ваш app.module .ts файл FullCalendarModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FullCalendarModule } from '@fullcalendar/angular'; // for FullCalendar!
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FullCalendarModule // for FullCalendar!
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

3-) теперь у вас есть полный календарь в. ваше приложение, так что попробуйте в свой компонент в:

a) html

<full-calendar defaultView="dayGridMonth" [plugins]="calendarPlugins"></full-calendar>

б) в ts

import { Component } from '@angular/core';
import dayGridPlugin from '@fullcalendar/daygrid'; //< import. it

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {

  calendarPlugins = [dayGridPlugin]; // important!

}

4-) Будьте осторожны .. как делают c говорит ... импорт. css MANUALLY в вашем css (или файле css):

 @import '~@fullcalendar/core/main.css';
@import '~@fullcalendar/daygrid/main.css';

Надеюсь, это поможет вам !!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...