@BeforeEach

export declare let BeforeEach: (Class: any, key: string, descriptor: PropertyDescriptor) => Function;

@BeforeEach decorator is used to apply any business logic before each action

@Controller({
   name: "home"
})
export class HomeController {

  @BeforeEach
  processBeforeEachAction() {
     return "-someLogic";
  }

  @Action("index")
  processIndexAction(@Chain data) {
      return "view" + data;
  }

  @Action("edit")
  processEditAction(@Chain data) {
     return "edit" + data;
  }

}

This will match route [home/index, home/edit, module/home/index, module/home/edit].

So in this case processBeforeEachAction will be invoked on any home controller route.

Expected result on home/index route will be "view-someLogic" and on edit "edit-someLogic";

results matching ""

    No results matching ""