Skip to main content

Implement runner using Angular

The Tripetto stock runners come with a built-in Angular component. This makes it very easy to use a runner in an Angular application. This quickstart shows how to use it.

✅ Add packages to your project​

First, you need to add the required packages to your project. To do so, run the following command:

npm install @tripetto/runner-autoscroll @tripetto/runner
info

The stock runners all depend on the Runner library. The Tripetto Runner library is the actual workhorse of the Tripetto runners. It parses the form definition and prepares it for UI rendering.

📄 Basic implementation​

To use the runner, simply import the module from the package and feed it to your application's @NgModule imports array. This makes the runner selector available in your application. The Angular component is located in a subfolder named angular inside the runner package. Here's an example:

app.module.ts
import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
import { AppComponent } from "./app.component";
import { TripettoAutoscrollModule } from "@tripetto/runner-autoscroll/angular";

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, TripettoAutoscrollModule],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}

Run Try on CodeSandbox

đŸ“Ĩ Collecting response data​

The next step is actual data retrieval from the form. To do so, you use the onSubmit event. This event fires when the form completes and the response data is ready for further processing. The event receives a reference to the active form instance. Together with one of the Export functions from the Runner library, you use it to retrieve data in a convenient format. The following example shows how to export the data using the exportables or CSV function.

app.module.ts
import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
import { AppComponent } from "./app.component";
import { TripettoAutoscrollModule } from "@tripetto/runner-autoscroll/angular";

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, TripettoAutoscrollModule],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}

Run Try on CodeSandbox

tip

The onSubmit event supports some additional features for error handling. Have a look at the Collecting response data guide for more information and guidance.

📖 Reference​

Have a look at the complete autoscroll runner API reference for detailed documentation. In the examples above, the following symbols were used:

⏭ī¸ Up next​

Now you've got the basic implementation for the runner up and running, dive deeper into the following topics: