如何用尊重窗口获取父视图的引用

时间:2018-06-19 04:41:38

标签: javascript extjs

在我的extJS应用程序中,我有一个按钮。点击那个按钮,我创建了一个窗口。我想访问父app的视图。怎么做到这一点。

我在这里尝试的是在windowController中

'use strict';
var http = require('http');
var request = require('request');
var body="";
exports.weatherWebhook = (req, res) => {
    const host = 'http://api.openweathermap.org/';
    const wwoApiKey = '7ffbb59524a81a6ac42ac3e942f68c5d';
    var city = req.body.queryResult.parameters['geo-city'];
    callWeatherApi(city).then((output) => {
        //console.log(output);
            res.json({ 'fulfillmentText': output }); // Return the results of the weather API to Dialogflow
     }).catch(() => {
        //console.log('ERROR');
            res.json({ 'fulfillmentText':'hello'});
    });
}
    function callWeatherApi (city) {
      return new Promise((resolve, reject) => {
        var path = 'data/2.5/weather?' +'APPID=' + wwoApiKey +
        '&q=' + encodeURIComponent(city)+'&units=imperial';
         request(host+path,function(error,res,body)
        {   
            /*var response = JSON.parse(body);
                var forecast = response['main']['temp'];
                var output='Current temperature is '+forecast;
                resolve(output);*/
            }).on('data', (d) => { body += d; console.log(body); })
        .on('end', () => {
            var response = JSON.parse(body);
                var forecast = response['main']['temp'];
                var output='Current temperature is ${forecast}';
                resolve('abc')})
        .on('error', (error) => {
                console.log(`Error calling the weather API: ${error}`)
                reject();
            });


  });
}

但是我在这里看到了窗户。我想看看基地。任何领导。

1 个答案:

答案 0 :(得分:3)

我认为您可以在创建窗口组件时传递父视图

Ext.create('Ext.window.Window', {
        xtype: 'window',
        parentView: view,
        ......
})

如果您共享代码会更有帮助。