Pages - jasperjs/jasper-application GitHub Wiki

Page it's component, which replies on specific application route. Due application build, page registers as

  1. Component;
  2. Template, which define the component;
  3. Route, which uses the template.

To create page type:

yo jasper:page <AREANAME> <PAGE-NAME> <ROUTE>

For instance:

yo jasper:page shop order-page /order

You can work with the page, like with components (it's the same). When user navigate to the page - defined component takes a control. Page, like a component also has a template.

By default app works through ngRoute. But your can override this behaviour to use custom router.

After pages is created - you can navigate by specified route.

How it works

After creating page configuration stores in _definition.json file. Build task read this configuration and generate area initialization file (_init.js). Build task create two registrations: component and page template:

jsp.template('#_page_homePage','<order-page></order-page>');
jsp.component({"route":"/order","ctor":"spa.shop.pages.OrderPage","name":"orderPage" /**/});

Also task register new route in jasperRouteProvider in routes configuration (_routes.js):

//...
jasperRouteProvider.setup( 
  {
    "routes": { 
      "/order": {
         "route":"/order",
         "name":"orderPage",
         "area":"shop", 
         "templateUrl":"#_page_orderPage"
      },
      // other routes
    }
  });
⚠️ **GitHub.com Fallback** ⚠️