0
MeteorJSのFlow Routerを使用してUncaught TypeError: pathDef.replace is not a function
コンソールエラーが発生しました。私はFlowにIron Routerを使用したことが新しく、正しく動作しない可能性があります。私が最初に別のページをロードしてからこのページに移動する場合、それは正常に動作しますが、私はページをリロード場合、私はエラーを取得することMeteorJS、Flow Router - キャッチされていないTypeError:pathDef.replaceが関数ではありません
注意。以下は
障害のあるコードです:
クライアントテンプレート
{{#if Template.subscriptionsReady}}
{{#each users}}
<tr>
<td>
{{linkNames profile.firstname profile.lastname}}
</td>
<td>
{{username}}
</td>
<td>
{{emails.[0].address}}
</td>
<td>
{{toUpperCase roles.[0]}}
</td>
<td>
{{getUsernameById createdBy}}
</td>
<td>
<a href="#" class="text-primary admin-edit-user" data-toggle="modal" data-target="#editUser" id="{{_id}}"><i class="fa fa-edit"></i></a>
</td>
<td>
<a href="#" class="text-danger admin-delete-user" id="delete{{_id}}"><i class="fa fa-times"></i></a>
</td>
</tr>
{{else}}
<tr>
<td colspan="6">
<p>There are no users</p>
</td>
</tr>
{{/each}}
{{else}}
<p>Loading...</p>
{{/if}}
パブ
/* Users */
Meteor.publish('users', function() {
if (Roles.userIsInRole(this.userId, ['admin', 'team'])) {
return Meteor.users.find({}, {
fields: {
'profile.firstname': 1,
'profile.lastname': 1,
'emails': 1,
'username': 1,
'roles': 1,
'createdBy': 1
},
sort: {'roles': 1}
})
} else if (Roles.userIsInRole(this.userId, ['client'])) {
return Meteor.users.find({}, {
fields: {
'profile.firstname': 1,
'profile.lastname': 1,
'emails': 1,
'username': 1
}
});
}
});
クライアントJS
/* On created */
Template.users.onCreated(function() {
var instance = this;
instance.autorun(function() {
instance.users = function() {
instance.subscribe(Meteor.users.find({}));
}
});
});
/* Helpers */
Template.users.helpers({
users: function() {
var users = Meteor.users.find({});
return users;
}
});
(ヘルパーが期待通りに動作しますが)、私はまた、次のグローバル・ヘルパーのために他のテンプレートでエラー
Exception in template helper: TypeError: Cannot read property 'username' of undefined
を取得
:
あなたの最初のエラーは、おそらくあなたのルーティングコード内のエラーが原因で起こっている/* Current Username */
Template.registerHelper('currentUsername', function() {
return Meteor.user().username;
});
ありがとう:にあなたのヘルパーを変更します!私は実際にこれを理解しましたが、この質問を閉じるのを忘れました。 私は上記のようにしました - 私の他の問題は、私がユーザーサブの前に存在しないページにリダイレクトしていたことでした。 ユーザーのpub/subがなくてもすべて正常に動作します。ユーザーのドキュメントは後で定義されるようになりました。 –