Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/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
Javascript 助手函数中的成员绑定返回未定义的_Javascript_Ember.js - Fatal编程技术网

Javascript 助手函数中的成员绑定返回未定义的

Javascript 助手函数中的成员绑定返回未定义的,javascript,ember.js,Javascript,Ember.js,尝试创建与用户id匹配的简单帮助器。其中一个值是Ember.binding,该值返回未定义的值 controller.js App.WorkspacesTasksController = Ember.ArrayController.extend({ needs: 'application', currentUserBinding: 'controllers.application.currentUser', ... }); Ember.Handlebars.registerHe

尝试创建与用户id匹配的简单帮助器。其中一个值是
Ember.binding
,该值返回未定义的值

controller.js

App.WorkspacesTasksController = Ember.ArrayController.extend({
  needs: 'application',
  currentUserBinding: 'controllers.application.currentUser',

  ...

});
Ember.Handlebars.registerHelper('isCurrentUser', function(currentUserId, taskUserId, options){
    currentUserId = Ember.Handlebars.get(this, currentUserId, options);
    taskUserId = Ember.Handlebars.get(this, taskUserId, options); 
    if (currentUserId === taskUserId) {
        return true;
    } else {
        return false;
    }
});
helper.js

App.WorkspacesTasksController = Ember.ArrayController.extend({
  needs: 'application',
  currentUserBinding: 'controllers.application.currentUser',

  ...

});
Ember.Handlebars.registerHelper('isCurrentUser', function(currentUserId, taskUserId, options){
    currentUserId = Ember.Handlebars.get(this, currentUserId, options);
    taskUserId = Ember.Handlebars.get(this, taskUserId, options); 
    if (currentUserId === taskUserId) {
        return true;
    } else {
        return false;
    }
});
我在模板中这样称呼它:

{{#isCurrentUser currentUser.id task.userObject.id}}
Matching users
{{/isCurrentUser}}
当我这样做时:
console.log(currentUserId)在我的助手中,我得到
未定义的


我做错了什么?

如果(true)返回true,否则返回false
,哦,天哪。您可以只编写
返回currentUserId===taskUserId
。好的一点,但没有回答这个问题。