Skip to main content

Usage with Angular

Starting with Tripetto is very easy when you are using Angular. Depending on your project's requirements there are two main Tripetto components to implement:

  • Form Runner component to run forms and collect responses. It handles form execution (including complex logic and response collection), form UI and form UX. Form respondents filling out a form are working in a runner;
  • Form Builder component to create forms. It is a visual UI component that allows building smart flowing forms and surveys like flowcharts in the browser. End users who edit forms are working in the builder.

🏃 Add a form to your Angular app

To add a form to your app, you first need to create a form. To do so, you can use the Tripetto Studio web app or add the form builder to your app (in case you want to allow users to create forms inside your app). Next, add the Angular component of one of the stock runners to your project and supply the form definition of your form to it.

1️⃣ 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

2️⃣ Implement runner component

The next step is to import and implement the Angular component. 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

▶️ Learn more

🏗️ Add the form builder to your Angular app

The Tripetto builder package comes with a built-in Angular component. This makes it very easy to use the builder in an Angular application.

1️⃣ Add package to your project

First of all, you need to add the Tripetto builder package to your project. This package is published on npm. To do so, run the following command:

npm install @tripetto/builder

2️⃣ Implement builder component

To use the component, simply import TripettoBuilderModule from the package and feed it to your application's @NgModule imports array. This makes the <tripetto-builder> selector available in your application. The Angular component is located in a subfolder named angular inside the builder 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 { TripettoBuilderModule } from "@tripetto/builder/angular";

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

Run Try on CodeSandbox

▶️ Learn more