What is the best way to link the data from the HTML input to the class property in the TypeScript file? (Combining Angular and IntroJs)

I'm working on an onboarding screen with Intro.js and need help with receiving user input. I've been trying different methods like [(ngModel)] = checked, [(checked)] = checked, (checked) = checked, but haven't had any success. Can anyone provide guidance on how to achieve this or confirm if it's possible?

import {Injectable} from '@angular/core';
import * as IntroJs from 'intro.js/intro.js';

@Injectable({
    providedIn: 'root'
})
export class IntrojsService {

    introJs = null;
    checked = false;
    
    constructor() {
    }
    
    welcome() {
        this.introJs = IntroJs();
        this.introJs.start();
        this.introJs.setOptions({
            tooltipClass: 'customTooltip',
            steps: [
                {
                    title: '<img src="../../assets/default-logo.png" alt="logo" class="logo">',
                    intro: '<div class="tooltip-container">\n' +
                        '\n' +
                        '    <div class="tooltip-body">\n' +
                        '        <p>Welcome to the site!</p>\n' +
                        '        <input type="checkbox" ngModel #checked"/>\n' + //input here
                        '    </div>\n' +
                        '</div>\n',
                },
            ],
        }).oncomplete(() => {
            console.log(this.checked);
        }).start();
    }
}

I want the value in the input to be assigned to the "checked" property of the class.

Answer №1

Here is a quick solution that you can try:

this.introJS.onbeforechange((e) => {
const el: HTMLInputElement = (<HTMLInputElement>document.getElementById('mycheckbox'));
  if (el) {
    this.checked = el.checked;
  }
});

this.introJS.setOptions({
  tooltipClass: 'customTooltip',
  steps: [
    {
      title: 'title',
      intro: '<div class="tooltip-container">\n' +
        '\n' +
        '    <div class="tooltip-body">\n' +
        '        <p>Welcome to the site!</p>\n' +
        '        <input type="checkbox" id="mycheckbox" />\n' + //input here
        '    </div>\n' +
        '</div>\n',
    },
    {
      title: 'title1',
    }
  ],
}).oncomplete((v) => {
}).start();

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring the use of a customizable decorator in Typescript for improved typing

Currently, I am in the process of creating TypeScript typings for a JavaScript library. One specific requirement is to define an optional callable decorator: @model class User {} @model() class User {} @model('User') class User {} I attempted ...

Construct this node project utilizing either gulp or webpack exclusively

In the structure of my project, you will find various folders like node, build, gulp, and src. These folders contain important files for the development process such as .gitignore, gulpfile.js, package.json, tsconfig.json, webpack.config.js, server.js, con ...

What is the method for configuring a timezone in Selenium Chromedriver?

I'm struggling to set a specific timezone while using Chromedriver. Is there an argument in ChromeOptions that can help with this? The problem arises when I visit certain websites (such as ), where it displays the system time based on Windows setting ...

The most lightweight scraper for individual website pages

There is a certain website that constantly updates its data. Unfortunately, there is no API available to access this information programmatically in JavaScript, which presents a common challenge for me. To tackle this issue, I have created a simple JavaSc ...

The module 'atptest' could not be located or its corresponding type declarations are missing. Error code: ts(2307)

After creating an angular library using angular cli, I encountered an issue when trying to use it in any angular application after publishing it to npm. The published library installs successfully with the command: npm i atptest This is how I attempted t ...

Issue with pushing inner list<object> in Knockout version 3.2.0

Currently, I am working with knockout.js on an ASP application. The issue I am facing involves a list of objects returned by the controller action to the view, where the objects in the list point to another list of objects. My struggle lies in adding new o ...

Saving in prettier differs from running it with npm

./file.ts (INCORRECT) import { jwtGroupClaimToRolesDomain, ScopeIds } from '@invison/shared'; import { Injectable, NestMiddleware } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Response } fro ...

Ways to use jQuery to disable row form elements in the second and third columns

I need a way to deactivate form elements in the second and third columns, starting from the second row until the nth row using a jQuery selector. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/> ...

To ensure that any changes made to data are reflected automatically when viewing data in Angular 2

In the process of developing an Angular 2 application, I encountered a scenario that requires special attention. The data displayed on the view is fetched from an API, with certain fields being editable by the user. These modifications can be saved using ...

Fade in and out on button press

There is a button with the following HTML code: <input type="submit" id="btnApply" name="btnApply" value="Apply"/> Upon clicking the button, a div should be displayed. <div> Thanks for applying </div> The display of the div should fade ...

What is the npm command in React to generate a new component?

As a newcomer to React, I am eager to learn how to generate a new component using a command. I am looking to replicate the functionality of the Angular 2 command "ng generate component Test" in React. After searching online, I came across a reference at ...

What is the method for launching a standalone terminal window from a vscode extension?

I am in the process of creating a custom extension for Visual Studio Code. My goal is to open a separate terminal window and execute multiple commands consecutively, similar to Terminal.sendText but not within the integrated terminal. Is there a method to ...

When adding my Angular web app to the home screen on iOS Safari, the icon appears as a screenshot instead of the specified apple-touch-icon

Despite adding an apple-touch-icon link to my index.html with a 150x150 PNG image, when I try to add my Angular web app as a shortcut to my iOS home screen from Safari, it only appears as a screenshot of the app page. Below is my HTML code: <!doctype ...

Require assistance with understanding the aes-256-cbc encryption using oaepHash

Procedure for Secure Data Encryption: Generate a random 256-bit encryption key (K_s). For each Personally Identifiable Information (PII) value in the payload: 1. Pad the plaintext with PKCS#7 padding. 2. Create a random 128-bit Initialization Vector (IV). ...

retrieving class instances from a Firebase database

I have a new group called GroupA group A { value1: string; value2: string; total(): number { return value1 + value2; } } I want to store instances of GroupA in my database, but when I retrieve them, they are in Object format which does not a ...

Revise a function that locates an object with a corresponding id in an array, modifies a property, and updates a React component's state

Here is a function that takes in a rating value within an object. The ID and Question properties remain unchanged, but the rating value can be updated. This will result in updating a React state value. Is there a method to improve the readability and con ...

Implementing Ajax Js to search within a specific div - reducing text overload on the page

Our e-shop on Prestashop requires an Ajax search feature to find compatible batteries and adapters on the page. Here is the code I have created: https://jsfiddle.net/fgfjo2n9/ I am facing two issues: • 1st I want the output to only display the heading ...

Task that merges multiple JSON files into one using Gulp

Within my directory, I have a collection of JSON files that contain arrays of objects. Folder A file1.json file2.json file3.json All the files in this folder have the same structure (a single array containing multiple objects). My goal is to execu ...

Persist form input data using ajax without any back-end server logic involved

Is there a solution for saving basic form data from a static webpage without using any server-side code? I have thought about potentially using MongoLab through a RESTful interface, but that would mean exposing API credentials on the client side and the ...

Deliver integers using Express.js

When I try to send a response with Express using the code below, it doesn't work: res.send(13245) An error message is displayed: express deprecated res.send(status): Use res.sendStatus(status) instead src/x.js:38:9 (node:25549) UnhandledPromise ...