Skip to content
Vladimir Enchev edited this page Mar 18, 2016 · 3 revisions

This is how you can configure you routes

//app/configs/routes.js
var RouteConfiguration = require('../../core/configuration/RouteConfiguration');
var Router = new RouteConfiguration();

/**
 * start
 */

/**
* If the request type is GET
* and the url path is "/"
* HomeController from app/controllers will be instantiated
* then index method in HomeController will be invoked
* then all dependencies from index method will be injected
*/
Router.get('/', 'HomeController@index');

/**
* If you want to pass dynamic parameters this is the example
* the name of the parameter is important, because if you want to get this parameter from $routeParams module,
* you need to know the name of the parameter
*/

Router.get('/user/{id}', 'UsersController@index');
/**
* Supported methods are
* - Router.get(path, controllerPattern)
* - Router.post(path, controllerPattern)
* - Router.put(path, controllerPattern)
* - Router.delete(path, controllerPattern)
*/

/**
 * end
 */
module.exports = Router;
//app/controllers/UsersController.js

class UserController {
    
    index($routeParams) {
        $routeParams.get('id');// => this is the id dynamic parameter defined in the routes
        //If the url is /users/68 the value of the id will be "68"
    }
}

pages

Clone this wiki locally