I need to know about the usage of iron router packae.I am using the latest version of meteor.
Issue : i am using Router.go('hello');
Router.go working fine.But the problem is append to the hello
template data to the already existing one.
Please see the below code :
router.js :
Router.map(function() {
this.route('home', {path: '/'});
this.route('hello',{path: 'hello'});
});
hello.html:
<Template name = "hello">
<h1>This is hello sections</h1>
</Template>
sampleApp.Html:
<head>
<title>sampleApp</title>
</head>
<body>
{{> hello1}}
</body>
<template name="hello1">
<h1>Hello World!</h1>
{{greeting}}
<input type="button" value="Click" />
</template>
sample.js
if (Meteor.isClient) {
Template.hello1.greeting = function () {
return "Welcome to sampleApp.";
};
Template.hello1.events({
'click input' : function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed the button");
Router.go('hello');
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
Output Displays :
Before Button Click :
Hello World!
Welcome to sampleApp.
**Button Click Me**
After Button Click :
Hello World!
Welcome to sampleApp.
**Button Click Me**
This is hello sections
Here the problem is Route.go not goes to new page.SO how to do.Please suggest me.
Thanks in Advance.
编辑:只需删除以下部分: <body> {{>hello1}} </body>
,它将按您想要的方式工作:) body标记内的内容将始终被呈现。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.