2016-04-28 109 views
0

我正在用accounts-password包编写一个meteor-angular2项目。如果他已经登录,发布给用户

我试图找出用户是否登录,如果他是,发布内容。

这是我的打字稿代码:

import {Meteor} from 'meteor/meteor'; 
import {RoomsCollection} from "../collections/rooms"; 

Meteor.publish('rooms',()=>{ 
    if (!this.userId) { 
     return null; 
    } else { 
     return RoomsCollection.find(); 
    } 
}); 

,你可以看到我使用this.userId但似乎this是不确定的。

这是错误:

TypeError: Cannot read property 'userId' of undefined 

我不太懂匿名函数都可以有this.userId,我实际上从2014年读的书“你第一次流星应用”,所以也许他们在哪里突破变化......或者我失去了一些东西。

我是新来的流星,所以关于这个问题的任何信息将不胜感激。

回答

相关问题