【问题标题】:angular2 fullcalendar not workingangular2 fullcalendar 不工作
【发布时间】:2017-11-23 22:05:37
【问题描述】:

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

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

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>

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

更新1,现在它不仅在重新启动机器时起作用。控制台说它在指定目录中找不到CalendarComponent

【问题讨论】:

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


    【解决方案1】:

    我有同样的问题,现在我的工作,请参考以下信息

    您需要将您的style.css 包含到

    导入完整的日历 css

    如果您使用的是 Angular CLI,这就像在 style.(scss|css) 文件中包含一行一样简单:

    @import "fullcalendar/fullcalendar.min.css"; 如果这不起作用,您可以尝试导入 fullcalendar。

    npm install --save fullcalendar 并包括:

    @import "../node_modules/fullcalendar/dist/fullcalendar.min.css";

    【讨论】:

      【解决方案2】:

      通过删除线解决了问题,

      身高:'父母'

      来自组件。像魅力一样工作

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-06-30
        • 1970-01-01
        • 2015-08-27
        • 1970-01-01
        • 2017-04-12
        • 2017-03-03
        • 2016-08-15
        • 2017-04-29
        相关资源
        最近更新 更多