Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 意外值';未定义';由模块导入';AppModule';_Ionic Framework_Ionic3 - Fatal编程技术网

Ionic framework 意外值';未定义';由模块导入';AppModule';

Ionic framework 意外值';未定义';由模块导入';AppModule';,ionic-framework,ionic3,Ionic Framework,Ionic3,我对爱奥尼亚一无所知,但我想尽快学习,我需要你的帮助。 基本上,使用ionic 3.19开发一个应用程序,该应用程序在两个选项卡(WeatherPage和ForecastPage)中显示当前天气和天气预报。 和获取:模块“AppModule”导入的意外值“undefined” 我的应用程序模块.ts: import { BrowserModule } from ‘@angular/platform-browser’; import { ErrorHandler, NgModule } from

我对爱奥尼亚一无所知,但我想尽快学习,我需要你的帮助。 基本上,使用ionic 3.19开发一个应用程序,该应用程序在两个选项卡(WeatherPage和ForecastPage)中显示当前天气和天气预报。 和获取:模块“AppModule”导入的意外值“undefined” 我的应用程序模块.ts

import { BrowserModule } from ‘@angular/platform-browser’;
import { ErrorHandler, NgModule } from ‘@angular/core’;
import { IonicApp, IonicErrorHandler, IonicModule } from ‘ionic-angular’;
import { SplashScreen } from ‘@ionic-native/splash-screen’;
import { StatusBar } from ‘@ionic-native/status-bar’;

import { MyApp } from ‘./app.component’;

import { WeatherApiPage } from ‘../pages/weather-api/weather-api’;
import { ForecastPage } from ‘../pages/forecast/forecast’;
import { WeatherPage } from ‘../pages/weather/weather’;
import { AppConstants } from ‘../providers/app-constants/app-constants’;
import { WeatherApi } from ‘../providers/weather-api/weather-api’;
import { ChartModule } from ‘highcharts’;

@NgModule({
declarations: [
MyApp,
WeatherApiPage,
ForecastPage,
WeatherPage
],
imports: [
ChartModule,
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
WeatherApiPage,
ForecastPage,
WeatherPage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
AppConstants,
WeatherApi
]
})
export class AppModule {}
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AppConstants } from '../../providers/app-constants/app-constants';
import { WeatherApi } from '../../providers/weather-api/weather-api';

/**
 * Generated class for the ForecastPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-forecast',
  templateUrl: 'forecast.html',
  providers: [AppConstants, WeatherApi]
})
export class ForecastPage {

  forecastForm: FormGroup;
  private appConstants: any;
  private weather: any;
  private geometry: any;
  private minWeather: number[][];
  private maxWeather: number[][];
  private weatherTime: any;
  weatherResult: boolean;
  summaryIcon: string;
  chartValue: {};

  constructor(private navController: NavController, private fb: FormBuilder, appConstants: AppConstants, weatherApi: WeatherApi) {
    this.forecastForm = fb.group({'location': ['', Validators.compose([Validators.required,Validators.pattern('[a-zA-Z, ]*'),
      Validators.minLength(3),Validators.maxLength(100)])],'forecastType': 'daily'});
    this.appConstants = appConstants;
    this.weather = weatherApi;
    this.geometry = { "longitude":"", "latitude":""};
    this.minWeather = new Array();
    this.maxWeather = new Array();
    this.weatherTime = new Array();
    this.weatherResult = false;
    this.summaryIcon ="";
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad ForecastPage');
  }

  filterJson(json,forecastType) {
    this.minWeather = new Array();
    this.maxWeather = new Array();
    this.weatherTime = new Array();
    for(var i=0;i<json.length;i++)
    {
      var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
      var b: Date = new Date(json[i].time * 1000);
      if(forecastType == "daily")
      {
        this.weatherTime.push(b.getDate()+" "+months[b.getMonth()]+" "+b.getFullYear());
        this.maxWeather.push(json[i].temperatureMax);
        this.minWeather.push(json[i].temperatureMin);
      }
      else
      {
        this.weatherTime.push(b.getDate()+" "+months[b.getMonth()]+" "+b.getFullYear() +" - "+b.getHours() +" hours");
        this.minWeather.push(json[i].temperature);
      }
    }
  }

  getForecast(formData: any) {
    this.weather.getGeometry(this.appConstants.getGoogleAPIURL(), formData.value.location).
    subscribe((data: any) => {
      this.geometry.longitude = data.results[0].geometry.location.lng;
      this.geometry.latitude = data.results[0].geometry.location.lat;
      this.weather.getCurrentWeather(this.geometry.longitude,this.geometry.latitude).
      subscribe((weatherData: any) => {
        this.weatherResult = true;
        if(formData.value.forecastType == "daily")
        {
          this.filterJson(weatherData.daily.data,formData.value.forecastType);
          this.chartValue = {
            title : { text : 'Weather Forecast' },
            chart: { type: 'column' },
            xAxis: { categories: this.weatherTime },
            series: [
              { name : 'Min Temp', data: this.minWeather},
              { name : 'Max Temp', data: this.maxWeather}
            ]
          };
        }
        else
        {
          this.filterJson(weatherData.hourly.data,formData.value.forecastType);
          this.chartValue = {
            title : { text : 'Weather Forecast' },
            chart: { type: 'column' },
            xAxis: { categories: this.weatherTime },
            series: [
              { name : 'Min Temp', data: this.minWeather},
              { name : 'Max Temp', data: this.maxWeather}
            ]
          };
        }
      });
    });
  }

}
有什么好办法吗?多谢各位

预测。ts

import { BrowserModule } from ‘@angular/platform-browser’;
import { ErrorHandler, NgModule } from ‘@angular/core’;
import { IonicApp, IonicErrorHandler, IonicModule } from ‘ionic-angular’;
import { SplashScreen } from ‘@ionic-native/splash-screen’;
import { StatusBar } from ‘@ionic-native/status-bar’;

import { MyApp } from ‘./app.component’;

import { WeatherApiPage } from ‘../pages/weather-api/weather-api’;
import { ForecastPage } from ‘../pages/forecast/forecast’;
import { WeatherPage } from ‘../pages/weather/weather’;
import { AppConstants } from ‘../providers/app-constants/app-constants’;
import { WeatherApi } from ‘../providers/weather-api/weather-api’;
import { ChartModule } from ‘highcharts’;

@NgModule({
declarations: [
MyApp,
WeatherApiPage,
ForecastPage,
WeatherPage
],
imports: [
ChartModule,
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
WeatherApiPage,
ForecastPage,
WeatherPage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
AppConstants,
WeatherApi
]
})
export class AppModule {}
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AppConstants } from '../../providers/app-constants/app-constants';
import { WeatherApi } from '../../providers/weather-api/weather-api';

/**
 * Generated class for the ForecastPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-forecast',
  templateUrl: 'forecast.html',
  providers: [AppConstants, WeatherApi]
})
export class ForecastPage {

  forecastForm: FormGroup;
  private appConstants: any;
  private weather: any;
  private geometry: any;
  private minWeather: number[][];
  private maxWeather: number[][];
  private weatherTime: any;
  weatherResult: boolean;
  summaryIcon: string;
  chartValue: {};

  constructor(private navController: NavController, private fb: FormBuilder, appConstants: AppConstants, weatherApi: WeatherApi) {
    this.forecastForm = fb.group({'location': ['', Validators.compose([Validators.required,Validators.pattern('[a-zA-Z, ]*'),
      Validators.minLength(3),Validators.maxLength(100)])],'forecastType': 'daily'});
    this.appConstants = appConstants;
    this.weather = weatherApi;
    this.geometry = { "longitude":"", "latitude":""};
    this.minWeather = new Array();
    this.maxWeather = new Array();
    this.weatherTime = new Array();
    this.weatherResult = false;
    this.summaryIcon ="";
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad ForecastPage');
  }

  filterJson(json,forecastType) {
    this.minWeather = new Array();
    this.maxWeather = new Array();
    this.weatherTime = new Array();
    for(var i=0;i<json.length;i++)
    {
      var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
      var b: Date = new Date(json[i].time * 1000);
      if(forecastType == "daily")
      {
        this.weatherTime.push(b.getDate()+" "+months[b.getMonth()]+" "+b.getFullYear());
        this.maxWeather.push(json[i].temperatureMax);
        this.minWeather.push(json[i].temperatureMin);
      }
      else
      {
        this.weatherTime.push(b.getDate()+" "+months[b.getMonth()]+" "+b.getFullYear() +" - "+b.getHours() +" hours");
        this.minWeather.push(json[i].temperature);
      }
    }
  }

  getForecast(formData: any) {
    this.weather.getGeometry(this.appConstants.getGoogleAPIURL(), formData.value.location).
    subscribe((data: any) => {
      this.geometry.longitude = data.results[0].geometry.location.lng;
      this.geometry.latitude = data.results[0].geometry.location.lat;
      this.weather.getCurrentWeather(this.geometry.longitude,this.geometry.latitude).
      subscribe((weatherData: any) => {
        this.weatherResult = true;
        if(formData.value.forecastType == "daily")
        {
          this.filterJson(weatherData.daily.data,formData.value.forecastType);
          this.chartValue = {
            title : { text : 'Weather Forecast' },
            chart: { type: 'column' },
            xAxis: { categories: this.weatherTime },
            series: [
              { name : 'Min Temp', data: this.minWeather},
              { name : 'Max Temp', data: this.maxWeather}
            ]
          };
        }
        else
        {
          this.filterJson(weatherData.hourly.data,formData.value.forecastType);
          this.chartValue = {
            title : { text : 'Weather Forecast' },
            chart: { type: 'column' },
            xAxis: { categories: this.weatherTime },
            series: [
              { name : 'Min Temp', data: this.minWeather},
              { name : 'Max Temp', data: this.maxWeather}
            ]
          };
        }
      });
    });
  }

}
从'@angular/core'导入{Component};
从“离子角度”导入{IonicPage,NavController,NavParams};
从“@angular/forms”导入{FormBuilder、FormGroup、Validators};
从“../../providers/app constants/app constants”导入{AppConstants};
从“../../providers/weather-api/weather-api”导入{WeatherApi};
/**
*为ForecastPage生成的类。
*
*看https://ionicframework.com/docs/components/#navigation 有关
*爱奥尼亚网页和导航。
*/
@IonicPage()
@组成部分({
选择器:“页面预测”,
templateUrl:'forecast.html',
提供者:[AppConstants,WeatherApi]
})
导出类预测页面{
预报格式:FormGroup;
私有appConstants:任何;
私人天气:有;
私人几何:任何;
二等兵明威瑟:号码[];
私人maxWeather:号码[];
私人天气时间:任何时间;
结果:布尔值;
摘要图标:字符串;
chartValue:{};
构造函数(专用navController:navController、专用fb:FormBuilder、appConstants:appConstants、weatherApi:weatherApi){
this.forecastForm=fb.group({'location':['',Validators.compose([Validators.required,Validators.pattern('[a-zA-Z,]*'),
Validators.minLength(3),Validators.maxLength(100)],'forecastType':'daily'});
this.appConstants=appConstants;
this.weather=weatherApi;
this.geometry={“经度”:“,”纬度”:“};
this.minWeather=新数组();
this.maxWeather=新数组();
this.weatherTime=新数组();
this.weatherResult=false;
this.summaryIcon=“”;
}
ionViewDidLoad(){
log('IonViewDidLoadForecastPage');
}
filterJson(json,forecastType){
this.minWeather=新数组();
this.maxWeather=新数组();
this.weatherTime=新数组();
对于(var i=0;i{
this.geometry.longitude=data.results[0].geometry.location.lng;
this.geometry.latitude=data.results[0].geometry.location.lat;
this.weather.getCurrentWeather(this.geometry.longitude,this.geometry.latitude)。
订阅((天气数据:任何)=>{
this.weatherResult=true;
if(formData.value.forecastType==“每日”)
{
this.filterJson(weatherData.daily.data、formData.value.forecastType);
this.chartValue={
标题:{文本:'天气预报'},
图表:{type:'column'},
xAxis:{categories:this.weatherTime},
系列:[
{name:'Min Temp',数据:this.minWeather},
{name:'Max Temp',数据:this.maxWeather}
]
};
}
其他的
{
this.filterJson(weatherData.hourly.data、formData.value.forecastType);
this.chartValue={
标题:{文本:'天气预报'},
图表:{type:'column'},
xAxis:{categories:this.weatherTime},
系列:[
{name:'Min Temp',数据:this.minWeather},
{name:'Max Temp',数据:this.maxWeather}
]
};
}
});
});
}
}

尝试使用原始代码制作chartmodule.forRoot(highcharts)

在app.module.ts中

import { ChartModule } from 'highcharts';
import * as highcharts from 'highcharts';

imports:[
 BrowserModule,
 ChartModule.forRoot(highcharts),
 IonicModule.forRoot(MyApp)
]

向我们显示您正在尝试导入AppModule的文件中写入的导入语句。您是指在main.ts中吗?从“./app.module”导入{AppModule};这个答案不是很有帮助-与其告诉他删除导入(这可能是必需的),不如试着解释一下为什么您认为这可能是一个问题,并建议如何解决。当然,ChartModule导入是forecastPage所必需的。您如何在forecastPage中使用highcharts?您使用的导入行是什么?事实上,正如您现在看到的,我没有在forecast.ts中导入ChartModule。模板分析错误:无法绑定到“options”,因为它不是“chart”的已知属性。(“][options]=“chartValue”>”):ng:///AppModule/ForecastPage。html@53:11“图表”不是已知元素:1。如果“图表”是一个角度组件,则确认它是该模块的一部分。2.若要允许任何元素,请将“无错误模式”添加到此组件的“@NgModule.schemas”。(“[ERROR->]”)