我想使用流星將一些數據從模板分享到另一個模板。我有一個模板,即allInventory.html我在其中顯示錶格中的一些數據我添加三個鏈接那裏。一個用於查看,編輯和刪除我想要的iam從後端獲取所有數據到helper之一即productDetails中,然後我將一個事件與視圖按鈕綁定,該按鈕將獲取當前用戶點擊哪個產品的數據,以便我成功獲取數據在我的所有庫存模板中,但還有另一個模板,即我想要呈現或顯示該數據的productDetails。但卡住了,我有allInventory點擊事件的數據,但不知道如何與productDetails模板的ishare相同。如何將一個模板的一些數據發送到另一個模板流星
這裏是我的allInventory.js
Template.allInventory.rendered = function() {
Template.allInventory.events({
"click .btn":function (e){
data = $(e.target).attr('data');
Router.go('productDetail', {data: $(e.target).attr('data')}, {query: 'q=s', hash: 'hashFrag'});
console.log("button clicked.."+data);
console.log(data);
}
})
ProductDetails.js
Template.productDetail.rendered = function() {
Template.productDetail.helpers({
productDetails: function() {
return data;
}
});
allInvenrtory.html
<button type="button" data ="{{productInfo}}" class="btn btn-info btn-sm"><i class="fa fa-eye"></i>View</button>
我只是單純的想與大家分享產品詳細模板allInventory模板數據。
任何幫助將appriciated! 謝謝