Dude
Dude

Reputation: 1045

Iron Router not working like expected

I play a bit around with Iron Router (Tutorial) but my templates don't work correct.

html:

<head>
  <title>MY TITLE</title>
</head>

<body>
  <h1>Welcome to Meteor!</h1>
</body>

<template name="hello">
  This is the hello template.
</template>
<template name="home">
  This is the home template.
</template>

JS

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

When I start meteor it renders the title in the head-section correctly but it is not showing any content from my templates in the body-section. Meteor is not throwing any errors but in the browser console I have 6 Errors:

[Error] TypeError: undefined is not a function (evaluating 'Template.__create__')
    (anonyme Funktion) (iron-dynamic-template.js, line 416)
    (anonyme Funktion) (iron-dynamic-template.js, line 433)
    global code (iron-dynamic-template.js, line 440)
[Error] TypeError: undefined is not an object (evaluating 'Parent.prototype')
    _inherits (meteor.js, line 220)
    (anonyme Funktion) (iron-layout.js, line 150)
    (anonyme Funktion) (iron-layout.js, line 487)
    global code (iron-layout.js, line 494)
[Error] TypeError: undefined is not a constructor (evaluating 'new Iron.Layout({template: this.options.layoutTemplate})')
    constructor (iron-router.js, line 1475)
    (anonyme Funktion) (iron-router.js, line 1771)
    (anonyme Funktion) (iron-router.js, line 1784)
    global code (iron-router.js, line 2356)
[Error] TypeError: undefined is not an object (evaluating 'Package['iron-router'].RouteController')
    global code (global-imports.js, line 3)
[Error] ReferenceError: Can't find variable: Template
    (anonyme Funktion) (template.bla.js, line 2)
    global code (template.bla.js, line 20)
[Error] ReferenceError: Can't find variable: Router
    (anonyme Funktion) (bla.js, line 1)
    global code (bla.js, line 6)

anyone have a clue whats wrong?

Upvotes: 0

Views: 841

Answers (2)

aladine
aladine

Reputation: 983

Maybe check your version first then update. Your error comes from library.

meteor remove iron:router
meteor update
meteor add iron:router

Upvotes: 1

Dude
Dude

Reputation: 1045

If you have the same Problem:

the answer is to NOT install iron router via meteorite. It seems like iron-router is now a smart package and you can add it now out of the box via meteor.

CORRECT Install iron-router via:

meteor add iron:router

WRONG (deprecated):

mrt add iron-router

Upvotes: 3

Related Questions