angular2 fullcalendar 不工作

标签 angular fullcalendar angular2-template angular2-services angular2-directives

您好,我在 angular2 项目中使用 fullcalendar。但是我无法正确显示日历本身。控制台中没有显示错误,但日历和事件不显示。这就是它现在显示的内容 enter image description here

这是我的代码。如果我需要附加更多文件,请告诉我

Angular.cli.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "calendar"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css",
        "../node_modules/fullcalendar/dist/fullcalendar.min.css"
        
      ],
      "scripts": [
        "../node_modules/jquery/jquery.js",
        "../node_modules/ap-angular2-fullcalendar/angular2-fullcalendar.js",
        "../node_modules/moment/moment.js"
      ],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import {CalendarComponent} from 'ap-angular2-fullcalendar/src/calendar/calendar'


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

app.component.ts

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

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  
  calendarOptions:Object = {
        height: 'parent',
        fixedWeekCount : false,
        defaultDate: '2016-09-12',
        editable: true,
        eventLimit: true, // allow "more" link when too many events
        events: [
          {
            title: 'All Day Event',
            start: '2016-09-01'
          },
          {
            title: 'Long Event',
            start: '2016-09-07',
            end: '2016-09-10'
          },
          {
            id: 999,
            title: 'Repeating Event',
            start: '2016-09-09T16:00:00'
          },
          {
            id: 999,
            title: 'Repeating Event',
            start: '2016-09-16T16:00:00'
          },
          {
            title: 'Conference',
            start: '2016-09-11',
            end: '2016-09-13'
          },
          {
            title: 'Meeting',
            start: '2016-09-12T10:30:00',
            end: '2016-09-12T12:30:00'
          },
          {
            title: 'Lunch',
            start: '2016-09-12T12:00:00'
          },
          {
            title: 'Meeting',
            start: '2016-09-12T14:30:00'
          },
          {
            title: 'Happy Hour',
            start: '2016-09-12T17:30:00'
          },
          {
            title: 'Dinner',
            start: '2016-09-12T20:00:00'
          },
          {
            title: 'Birthday Party',
            start: '2016-09-13T07:00:00'
          },
          {
            title: 'Click for Google',
            url: 'http://google.com/',
            start: '2016-09-28'
          }
        ]
      };
}

app.component.html

<angular2-fullcalendar [options]="calendarOptions"></angular2-fullcalendar>

请帮忙。我被困住了。任何帮助将不胜感激。谢谢

Update 1,Now it is not working only on restarting the machine.The console says its not finding CalendarComponent in the specified directory

最佳答案

通过删除该行解决了问题,

height:'parent'

来自组件。工作起来很有魅力

关于angular2 fullcalendar 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44668692/

相关文章:

javascript - Angular2 - 将 'activatedRoute.params' 变成 promise

javascript - 日期范围内的完整日历显示

javascript - 某些事件会显示,但另一些事件不会显示在 FullCalendar 中

Angular ContentChildren 获取指令输入和 TemplateRef

angular - 如何从组件模板中将数组作为 Input() 传递?

javascript - 具有多个参数的 Angular 2 路由器链接

c# - 在 SSL/TLS 证书下,对 ASP.NET 的 Angular 请求返回 "Error Unknown"

javascript - 我怎样才能听到输入的变化然后改变文本?

javascript - 如何在不影响原始数组的情况下删除值和键?

javascript - jQuery 全日历 : How can I target and change the background color of the days that don't belong to the current month?