【问题标题】:angular2 gulp task is compiling but with errorsangular2 gulp 任务正在编译但有错误
【发布时间】:2016-09-23 04:18:33
【问题描述】:

我正在处理一个 gulpfile,我想在其中编译 angular 2 应用程序,但出现一些错误:

“...”类型上不存在它是什么意思,我如何使它存在?其中 nativeWindow 是 window.service.ts 如下所示:

//--------------------------------------------------------------------------------------------------
// Imports Section:
//--------------------------------------------------------------------------------------------------
import {Injectable} from 'angular2/core'
import {window} from 'angular2/src/facade/browser';

//--------------------------------------------------------------------------------------------------
// Service Class:
//--------------------------------------------------------------------------------------------------
@Injectable()
export class WindowService {
    //----------------------------------------------------------------------------------------------
    // Constructor Method Section:
    //----------------------------------------------------------------------------------------------
    constructor() { }

    //----------------------------------------------------------------------------------------------
    // Public Properties Section:
    //----------------------------------------------------------------------------------------------
    get nativeWindow(): Window {
        return window;
    }
}

【问题讨论】:

  • 很难从你的截图中看出。 preferences 是什么类型的? window 也应该是你的服务?
  • 另外,为什么你还有一个返回 window 对象的服务呢?我没有看到这个的用例。

标签: typescript angular


【解决方案1】:

您收到的错误消息表明,例如在 preferences 上找不到属性 range。这同样适用于您的WindowService。在您的吸气剂中,您返回 window 对象,在您的组件中,您尝试访问该 window 对象上的 offerResults。该属性对window 对象没有任何意义,因为该对象表示浏览器中打开的窗口,我不会在该对象中存储任何数据。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多