angular - 全日历和 Angular 5

标签 angular typescript fullcalendar fullcalendar-scheduler

(新新编辑)

Rustam 帮助 Arshaw 构建了一个很棒的 Angular 模块!看看这个。适用于 Angular 7。

https://fullcalendar.io/docs/angular

(新编辑)

我用 FullCalendar 实现了 Angluar 5 @Alpha Release .

我之前在下面将 FullCalendar 实现到 Angular 时遇到了问题。我想你们可能也想要更新。


如何使用 Angular 5 正确实现 fullcalendar 而不会出现任何错误?我正在尝试将其实现到特定组件中。我安装了以下软件包

  • j查询
  • 时刻
  • 全日历
  • fullcalendar-scheduler

仅供引用,下面的帖子是我最接近找到解决方案的帖子。我按照说明进行操作,但仍然收到“JQueryPromise”错误。请提前告知并感谢!

Callback angular function from jquery event

package.json

 "fullcalendar": "^3.8.0",
 "fullcalendar-scheduler": "^1.9.1",
 "jquery": "^3.2.1",
 "moment": "^2.20.1",

.angular-cli.json

 "styles": [
    "styles.css",
    "../node_modules/fullcalendar/dist/fullcalendar.min.css",
    "../node_modules/fullcalendar-scheduler/dist/scheduler.min.css"
  ],
  "scripts": [
    "../node_modules/jquery/dist/jquery.min.js",
    "../node_modules/moment/min/moment.min.js",
    "../node_modules/fullcalendar/dist/fullcalendar.min.js",
    "../node_modules/fullcalendar-scheduler/dist/scheduler.min.js"
  ],

main.ts

import * as jQuery from "jquery";
(window as any).$ = (window as any).jQuery = jQuery;

app.component.html

<div id='calendar'></div>

app.component.ts

import { Component } from '@angular/core';
import 'fullcalendar';
import 'fullcalendar-scheduler';
declare let $: any;

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  ngOnInit() {
    $('#calendar').fullCalendar({});
  }
}

我虔诚地遵循了所有步骤,但我仍然遇到错误。具有讽刺意味的是,当我刷新页面时它能够加载并且我可以绕过该错误,但它仍然存在,尤其是当我第一次运行“ng serve”时

ERROR in node_modules/fullcalendar/dist/fullcalendar.d.ts(695,36): error TS2304: Cannot find name 'JQueryPromise'.
node_modules/fullcalendar/dist/fullcalendar.d.ts(696,29): error TS2304: Cannot find name 'JQueryPromise'.
node_modules/fullcalendar/dist/fullcalendar.d.ts(697,20): error TS2304: Cannot find name 'JQueryPromise'.
node_modules/fullcalendar/dist/fullcalendar.d.ts(759,22): error TS2304: Cannot find name 'JQueryPromise'.
node_modules/fullcalendar/dist/fullcalendar.d.ts(775,50): error TS2304: Cannot find name 'JQueryPromise'.
node_modules/fullcalendar/dist/fullcalendar.d.ts(988,23): error TS2304: Cannot find name 'JQueryEventObject'.
node_modules/fullcalendar/dist/fullcalendar.d.ts(1401,70): error TS2304: Cannot find name 'JQueryAjaxSettings'.
node_modules/fullcalendar/dist/fullcalendar.d.ts(1603,50): error TS2304: Cannot find name 'JQueryPromise'.
node_modules/fullcalendar/dist/fullcalendar.d.ts(1623,50): error TS2304: Cannot find name 'JQueryPromise'.
node_modules/fullcalendar/dist/fullcalendar.d.ts(2588,50): error TS2304: Cannot find name 'JQueryPromise'.

New development down this rabbit hole

刚刚尝试创建一个新组件“schedule.component”并将所有内容移到那里,但现在出现以下错误

Refused to load the font 'data:font/woff;base64,d09GRgABAAAAAGVUABEAAAAAxuQAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABHREVGAAABgAAAAC4AAAA0ArgC7UdQT1MAAAGwAAAQ6AAALgxKsqRTR1NVQgAAEpgAAAH3AAAELqI5y+RPUy8yAAAUkAAAAE8AAABgaGyBu2NtYXAAABTgAAABlAAAAkQkRATXY3Z0IAAAFnQAAABeAAAAugDsQf1mcGdtAAAW1AAABZcAAAvNb3/BHGdhc3AAABxsAAAACAAAAAgAAAAQZ2x5ZgAAHHQAAEApAAB3CtbiupxoZWFkAABcoAAAADYAAAA2BkubWWhoZWEAAFzYAAAAIAAAACQHFARfaG10eAAAXPgAAAI6AAAEEk4TN4Nsb2NhAABfNAAAAhIAAAISiLhpam1heHAAAGFIAAAAIAAAACACigzgbmFtZQAAYWgAAACUAAABHhQGLdJwb3N0AABh/AAAAq4AAASRk5y6n3ByZ...QxUajCCFt4p9HP4fzdSWs2XhWl5HvJazrIrFUyB0l5dpqcW10lV2wukjMLuAvyMHNiYpgPsrCVXZDKrkpll6UWkh7kABVAFVCDe7UFmxagDegA+hLHRPbqtMo7ZHCpKdT6tPGXybzo0+RXBLoPZt1tELcXxCmAAyZwYTJvdDFZKnDER44X2451rDqCyunIsRWvLSx6wnWqwPj/uX5/KuEy6DL0z6A/Fn79VihxMFJsrlAFy4DpZOcvNlMeNp+BRDLj0r+XFdRxdSNSNxiI/AL3ojKdAAB4AWPw3sFwIihiIyNjX+QGxp0cDBwMyQUbGdictkUwWDAwsDJogTgOPN4c9iz6bMos4iysHFChUDZXJnMWTSZZJrAQt9M+YQYBBh4GTgY2kEZOoJiA0z4GBxiEiDEzuGxUYewIjNjg0BGxkTnFZaMaiLeLo4GBkcWhIzkkAqQkEggceHw5HFkM2VRZJFlYebR2MP5v3cDSu5GJwWUDW9xG1hQXAFAmKZU=' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback.

最佳答案

由于您提出的 GitHub 问题,您遇到的问题现已得到解决。

我相信运行 npm install --save-dev @types/jquery 会正确解决这个问题,因为我遇到了同样的问题,并且运行它成功了(在我找到这篇文章和GitHub 问题的链接)。

引用 GitHub 上的修复:“现在在文档中说明了这一点:https://fullcalendar.io/docs/typescript/

关于angular - 全日历和 Angular 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47950588/

相关文章:

javascript - 在 Meteor 中更改 URL 后重新呈现 fullCalendar

angular - [Angular7][Jest] 如何测试 MergeMap?

css - Angular-cli 构建生成的 CSS 未在 DOM 中解释

angular - 在 Ionic 3 中使用全局变量时出错

typescript - 如果属性具有特定值,则向 typescript 界面添加条件属性

reactjs - 确保路径由变量定义的嵌套字段在添加到依赖项数组时触发 React.useMemo 更新

Angular Fire (Google) Analytics 事件显示在 Chrome GA 调试工具中,但未登录到 Firebase

javascript - Google Maps InfoWindow -(单击)触发 Angular 2 函数

fullcalendar - 使用 Fullcalendar 和 Google 日历为过去的事件添加类(class)

全日历时间间隔