Skip to content

Creating your first page

Maxime Séguin edited this page May 19, 2015 · 1 revision

Type this line in the system console:

yo koco:page home

home being the name of the page. By contention, this will create a folder "home-page" in the "components" folder of your koco project. Normally (except "html only" pages), a page consists of a "view model" (JavaScript) file and a view (html) file. A koco page is nothing more than a KnockoutJS Component. See KnockoutJS Components for more information.

This will also register the page in the "components.js" file.

The generator will ask for:

  • Is the page html only: If the page has no specific behaviour other than displaying some data, you can choose to make it "html only". This will create only one file (html) instead of the normal 2 files (view model & view)

    press enter to select default (No)

  • Do you need an activator for this page: An activator is a module (JavaScript file) responsible to do some stuff (it can be asynchronous) before a page is rendered, including telling the router if the URL exists or not. It can, by example, call an API for a specific content based on a URL parameter (id).

    press enter to select default (No)

  • What's the title of your new page: The title will be part of the page configuration, and the value will be passed along to the "view model".

    type home and press enter

Important: A page is not a route. To use this page, you will have to add a route and associate it to this page.

Clone this wiki locally