angularjs - How to access helpers in controller and why is my find() empty? -
i'm pretty new new meteor 1.3.1. i've never worked helpers before.
this helper:
this.helpers({ questions() { return questions.find({categoryid: this.categoryid}); } });
first question: how access helper (questions
) within it's own controller? tried $scope.questions
, this.questions
, this.play.questions
(play
alias of controller). undefined
. in view iterate ng-repeat='question in play.questions'
, works fine.
then thought maybe helpers can't accessed in controller. tried this: this.questions = questions.find({categoryid: this.categoryid});
but here problem empty cursor. idea why is?
i assume in controller function , have used
$reactive(this).attach($scope)
before
this.questions = questions.find({category: this.categoryid});
? 1 reason cursor empty when not using helper might subscription not ready time set this.questions
. therefore should make assignment reactive wrapping inside this.autorun
. doing cursor gets updated client side collection populated.
i think instead of calling helper within controller should extract common function , use inside helper , whereever else need it. helpers used data ui if not mistaken (<- ?).
Comments
Post a Comment