angular 2打字稿调用函数

时间:2016-10-25 17:57:32

标签: javascript angularjs typescript

请检查以下代码。我正在研究" Angular2 CLI"生成的mapper(Apple, appleTable, properties = { "appleBloggers": relationship(Blogger, secondary=join(Recipe, Blog, Recipe.id == Blog.recipeId), secondaryjoin=lambda: and_(Apple.id == Recipe.appleId, Blogger.id == Blog.bloggerId), viewonly=True) }) 第一次使用打字稿。我在匿名函数中调用类函数时遇到了问题。

例如,我想在Regex regex = new Regex("OnError(.*)End Log"); var matches = regex.Matches(yourString); foreach(Match match in matches) ....

中调用angular 2函数

我在想什么!错〜

抱歉我的英文。

readFile()

在组件中:

showDialog()

1 个答案:

答案 0 :(得分:1)

您的函数表达式不会保留封闭的this。请改用箭头功能:

 return Observable.create((observer) => {
            dialog.showOpenDialog({
                properties: ['multiSelections'],
                filters: [
                    {name: 'Images', extensions: this.ImageExtensions}
                ]
            }, (fileNames) => { // <---- here ----
                if (fileNames === undefined) {
                    observer.error("ERROR");