简体   繁体   English

如何在ionic2中添加外部json值

[英]how to add external json values in ionic2

I have a json data in one js file.in IONIC2 i need to get that value from that file and assign to an another variable in constructor..? 我在一个js文件中有一个json数据。在IONIC2中,我需要从该文件中获取该值并分配给构造函数中的另一个变量。 how to achieve this 如何做到这一点

export class RangenavigatorDefaultPage {
  rangeData: any;
  constructor(private nav: NavController,) {
     rangeData = //need to add that json variable from external js
   }

}

export the json data from the file. 从文件中导出json数据。 import the json into this file. 将json导入此文件。

FILE 1: 文件1:

export settings = {
  a: 1,
  b: 2
};

FILE 2: 文件2:

import { settings } from './file1';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM