无法解析AnalysisComponent的所有参数:([object Object],?,?,[

时间:2017-07-26 08:18:41

标签: angular typescript

首先,我是角度框架的初学者。

当我添加项目的服务时,我得到了这个错误。

  

错误:无法解析AnalysisComponent的所有参数:([object Object],?,?,[object Object],[object Object],[object Object],[object Object],[object Object])。

Angular 4.0.0

我无法理解如何解决它。

calendar.component.ts:

    import { Component, ChangeDetectionStrategy, Inject, ViewChild, TemplateRef, OnInit } from '@angular/core';
    import { DOCUMENT } from '@angular/platform-browser';
    import { Router } from '@angular/router';
    import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
    import { InternService } from '../intern.service';
    import { AuthService } from '../../user/auth.service';
    import { ToastrService } from '../../common/toastr.service';
    import { IIntern } from '../intern';

    import {
      startOfDay,
      endOfDay,
      subDays,
      addDays,
      endOfMonth,
      isSameDay,
      isSameMonth,
      addHours
    } from 'date-fns';

    import { Subject } from 'rxjs/Subject';

    import {
      CalendarEvent,
      CalendarEventAction,
      CalendarEventTimesChangedEvent
    } from 'angular-calendar';

    const colors: any = {
      red: {
        primary: '#ad2121',
        secondary: '#FAE3E3'
      },
      blue: {
        primary: '#1e90ff',
        secondary: '#D1E8FF'
      },
      yellow: {
        primary: '#e3bc08',
        secondary: '#FDF1BA'
      }
    };

    export interface IEvent {
      start: Date,
      end: Date,
      title: string,
      color: { primary: string, secondary: string },
      actions: CalendarEventAction[]
    }

    @Component({
      selector: 'app-fullcalendar',
      changeDetection: ChangeDetectionStrategy.OnPush,
      templateUrl: './calendar.component.html',
      styleUrls: ['./calendar.component.scss']
    })
    export class AnalysisComponent implements OnInit {

      @ViewChild('modalContent') modalContent: TemplateRef<any>;

      view = 'month';

      viewDate: Date = new Date();

      modalData: {
        action: string,
        event: CalendarEvent
      };

      actions: CalendarEventAction[] = [{
        label: '<i class="editButton"></i>',
        onClick: ({ event }: { event: CalendarEvent }): void => {
          this.handleEvent('Edited', event);
        }
      }, {
        label: '<i class="deleteButton"></i>',
        onClick: ({ event }: { event: CalendarEvent }): void => {
          this.events = this.events.filter(iEvent => iEvent !== event);
          this.handleEvent('Deleted', event);
        }
      }];

      refresh: Subject<any> = new Subject();

      events: CalendarEvent[] = [];

      ngOnInit() {
        this.internService.getInternsByOption('all')
          .subscribe(data => {
            if (data.success === false) {
              if (data.errcode) {
                this.authService.logout();
                this.router.navigate(['login']);
              }
              this.toastr.error(data.message);
            } else {
              console.log(data.data);
            }
          });
      }

      activeDayIsOpen = true;

      constructor(private modal: NgbModal,
        private iintern: IIntern, private ievent: IEvent,
        private internService: InternService,
        private toastr: ToastrService,
        private router: Router,
        private authService: AuthService,
        @Inject(DOCUMENT) doc: any) { }

      dayClicked({ date, events }: { date: Date, events: CalendarEvent[] }): void {

        if (isSameMonth(date, this.viewDate)) {
          if (
            (isSameDay(this.viewDate, date) && this.activeDayIsOpen === true) ||
            events.length === 0
          ) {
            this.activeDayIsOpen = false;
          } else {
            this.activeDayIsOpen = true;
            this.viewDate = date;
          }
        }
      }

      eventTimesChanged({ event, newStart, newEnd }: CalendarEventTimesChangedEvent): void {
        event.start = newStart;
        event.end = newEnd;
        this.handleEvent('Dropped or resized', event);
        this.refresh.next();
      }

      handleEvent(action: string, event: CalendarEvent): void {
        this.modalData = { event, action };
        this.modal.open(this.modalContent, { size: 'lg' });
      }

      addEvent(): void {
        this.events.push({
          title: 'New event',
          start: startOfDay(new Date()),
          end: endOfDay(new Date()),
          color: colors.red,
          draggable: true,
          resizable: {
            beforeStart: true,
            afterEnd: true
          }
        });
        this.refresh.next();
      }

      eventCreator(eventintern: IIntern) {
        let a = this.ievent;
        a.start = eventintern.starteddate;
        a.end = eventintern.endeddate;
        a.color = colors.red;
        a.actions = this.actions;
        this.events.push(a);
      }
    }

1 个答案:

答案 0 :(得分:2)

你的问题在这里:

popup.BeginAnimation(UIElement.OpacityProperty,
    new DoubleAnimation
    {
        To = 0,
        Duration = TimeSpan.FromSeconds(0.5),
        AutoReverse = true,
        RepeatBehavior = RepeatBehavior.Forever
    });

从构造函数constructor(private modal: NgbModal, private iintern: IIntern, private ievent: IEvent, private internService: InternService, private toastr: ToastrService, private router: Router, private authService: AuthService, @Inject(DOCUMENT) doc: any) { } private iintern: IIntern, private ievent: IEvent中删除以下内容,我不完全确定@Inject(DOCUMENT) doc: any的用途是什么?

我看到从被删除的项目中使用的唯一一行是doc。如果您需要将它们用作varibales,您可以将它们添加到组件的顶部,如下所示:

private ievent: IEvent

您的构造函数应如下所示:

export class AnalysisComponent implements OnInit {
  public event: IEvent;
  public intern: IIntern;
  public doc: DOCUMENT;