Controller.setAction >= 1.1.0

Purpose

Add an action to the current class

Syntax

Controller.setAction ( Stringname Functionfnc );

Parameters

name
The name of the action
fnc
The actual function

Examples

Add a new action to a class


// Create a new "Page" controller
var Page = Function.inherits('Alchemy.Controller.App', function Page(conduit, options) {
	Page.super.call(this, conduit, options);
});

// Now add a "index" action, the name is taken from the function
Page.setAction(async function index(conduit) {
    
    var pages = await this.model.find('all');
    
    this.set('pages', pages);
    this.render('pages/index');
});