Can';在nativescript的console.log()中看不到值

Can';在nativescript的console.log()中看不到值,nativescript,angular2-nativescript,nativescript-angular,Nativescript,Angular2 Nativescript,Nativescript Angular,我有一个js文件,其中包括一个数组!js文件与此类似 export const appointments = [ { "taskID": 9018929, "resource_ID": 1, "title": "KNDL Thatcham", "description": "<Non-Selected>\r\n10:00 - 18:00", "startTime": "2018-12-28T00:00:00", "endTime": "2018-12-28T2

我有一个js文件,其中包括一个数组!js文件与此类似

export const appointments = [
{
  "taskID": 9018929,
  "resource_ID": 1,
  "title": "KNDL Thatcham",
  "description": "<Non-Selected>\r\n10:00 - 18:00",
  "startTime": "2018-12-28T00:00:00",
  "endTime": "2018-12-28T23:59:00",
  "statusColour": "#DFDFDF",
  "clientColour": "#FFFDD7"
}]
这是我正在导入服务的组件。ts

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

import { CalendarService } from "./service/calendar.service";
import { RadCalendar, CalendarEvent, CalendarSelectionEventData } from "nativescript-ui-calendar";
@Component({
  selector: 'ns-calendar',
  templateUrl: './calendar.component.html',
  styleUrls: ['./calendar.component.css'],
  moduleId: module.id,
  providers: [CalendarService]
})
export class CalendarComponent implements OnInit {
}

您需要将calendarService类型的私有calendarService参数添加到构造函数中

创建CalendarComponent时,系统将calendarService参数设置为calendarService的singleton实例

导出类CalendarComponent实现OnInit{ 构造函数(calendarService:calendarService){}


}

您确定正在实例化
CalendarService()
?如果移动
console.log(约会),会发生什么情况
在类定义之外(即,直接在
导入
)之后?@DacreDenny我已经在另一个组件中导入了service.ts!我会让你知道,如果它的工作后,进口部分!再次检查代码,我已经在导入服务的位置添加了组件。t您刚才提到了
提供者
。我认为在您将
CalendarService
的实例注入组件的构造函数之前,不可能创建它<代码>构造函数(private _calendarApiService:calendarApiService){}我仍然没有在终端中获得console.log()!我看过tns医生了!一切都好!但它仍然没有显示!尝试在构造函数中包含console.log,以确保caldendarComponent正在尝试initiatedI。但是它没有出现!这是我在终端“在设备LGAS992174f3745上成功同步应用程序org.nativescript.UnityMobile”中找到的消息。已跳过挂钩,因为正在进行捆绑或livesync。正在准备项目。。。项目已成功准备(Android)已成功在设备LGAS992174f3745上传输api.service.js。正在重新启动设备LGAS992174f3745上的应用程序。。。设备:LGAS992174f3745调试端口:40000让我们使用。
import { Component, OnInit } from '@angular/core';

import { CalendarService } from "./service/calendar.service";
import { RadCalendar, CalendarEvent, CalendarSelectionEventData } from "nativescript-ui-calendar";
@Component({
  selector: 'ns-calendar',
  templateUrl: './calendar.component.html',
  styleUrls: ['./calendar.component.css'],
  moduleId: module.id,
  providers: [CalendarService]
})
export class CalendarComponent implements OnInit {
}