/java-script/

MeteorJS - Router

2014-06-03 23:16:11

Install Meteor curl https://install.meteor.com/ | sh

If you don't have nodeJs install form http://nodejs.org/ (somthing like this sudo apt-get install nodejs)

Install Meteorite for Meteor sudo npm install -g meteorite

Add Router package to Meteor sudo add iron-router

Create new application meteor create appname

Run app meteor

if (Meteor.isClient) {

    Router.map(function () {
        this.route('home', {path: '/'})
        this.route('post', {path: '/post'});
        this.route('about', {path: '/about'});
    });

}

if (Meteor.isServer) {
    Meteor.startup(function () {
        // code to run on server at startup
    });
}

<head>
<title>MeteorJS-hello</title>
</head>

<body>
<a href='"/"'>Home</a>
<a href='"/post"'>Post</a>
<a href='"/about"'>About</a>
</body>

<template name='"home"'>

# Home

</template>
<template name='"about"'>

# About

</template>
<template name='"post"'>

# Post

</template>