There was an issue with the DOM where it was reported that the string contains an

HTML document

<div>
    <header>Welcome Page</header>
    <p><b>{{title}}{{text}}</b></p>
    <button type="button" class="btn btn-info" (click)="onClickMe($event)">Info</button>
    <br>
    <br>
    <rating [rating]="5"></rating>
    <div *ngFor="let image of getImages">
        <!-- {{image}} -->
        <catpicture [data="image"]></catpicture>
    </div>
</div> 

Login Control file

import { Component,Input } from '@angular/core';
import { catPicture } from './login.loginname';

@Component({
  selector: 'catpicture',
  templateUrl: './login.component.html',
  styleUrl: './login.component.scss',
  providers: [catPicture]
})

export class LoginComponent {
  title = "My First Angular App";
  text = " Universe";


  onClickMe($event: any) {
    console.log("Clicked",$event);
  }

  getImages;
  constructor(catPicture:catPicture){
    this.getImages=catPicture.getPictures();
  }
  
  // @Input()data:any
}

Loginname.ts

export class catPicture{
    getPictures(){
        return [
            {
            imageUrl: "http://loremflickr.com/150/150?random=1",
            imageTitle: "Product 1",
            postDate: "May 31, 2018",
            description: "Cras sit amet nibh libero, in gravida...",
            rating:4
            },
            {
                imageUrl: "http://loremflickr.com/150/150?random=2",
                imageTitle: "Product 2",
                postDate: "May 31, 2018",
                description: "Cras sit amet nibh libero, in gravida...",
                rating:3
            },
            {
                imageUrl: "http://loremflickr.com/150/150?random=3",
                imageTitle: "Product 3",
                postDate: "May 31, 2018",
                description: "Cras sit amet nibh libero, in gravida...",
                rating:3
            },
            {
                imageUrl: "http://loremflickr.com/150/150?random=4",
                imageTitle: "Product 4",
                postDate: "May 31, 2018",
                description: "Cras sit amet nibh libero, in gravida...",
                rating:3
            }
        ];
    }
}

catpicture.ts

import { Component, Input } from "@angular/core";
// import { getCatpictures } from './login.canpicture';

@Component({
    selector:'catpicture',
    template:`
    <div class="media">
        <img class="mr-3" src="{{data.imageUrl}}" alt="GeneralPicture">
        <div class="media-body">
            <h5 class="mt-0">Title</h5>
            {{data.postDate}}
            <br>
            {{data.description}}
        </div>
    </div>
    `,
    styles:[`
        .media{
            margin-bottom:20px;
        }
    `]
})

export class catPicture{
    @Input() data: any;
}

module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';
import { MovieComponent } from './movie/movie.component';
import { HomeComponent } from './home/home.component';
import { catPicture } from './login/login.loginname';

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
    MovieComponent,
    HomeComponent,
  ],
  imports: [
    BrowserModule,
    AppRoutingModule
  ],
  providers: [catPicture],
  bootstrap: [AppComponent]
})
export class AppModule { }

and the web page displays as follows:view image here

ERROR DOMException: Invalid character in string

After examining the HTML code file again, I am unable to resolve this issue due to its simplicity. As a novice learner, can someone provide guidance on how to address this bug? Thank you for your assistance!

Any suggestions on resolving this?

Answer №1

Please make a correction to the following line in the initial HTML file.

<catpicture [data]="catpicture"></catpicture>

Answer №2

<dogimage [info="dogphoto"]></dogimage>

replace with

<dogimage [info]="dogphoto"></dogimage>

Answer №3

The solution To create the specified HTML file, use the following code:

<div>
    <header>Login Page</header>
    <p><b>{{title}}{{text}}</b></p>
    <!-- <ul> -->
        <!-- <li *ngFor="let loginname of loginnames">
            {{loginname}}
        </li> -->
    <button type="button" class="btn btn-info" (click)="onClickMe($event)">Info</button>
    <br>
    <rating [rating]="3"></rating>
    <br>
    <rating [rating]="5"></rating>
    <!-- <div *ngFor="let catpicture of getPictures">
        <catpicture [data]="catpicture"></catpicture>
    </div> -->
    <div *ngFor="let picture of getPictures">
        <img [src]="picture.imageUrl" alt="{{ picture.pictureName }}">
        <p>{{ picture.pictureName }}</p>
        <p>{{ picture.postDate }}</p>
        <p>{{ picture.description }}</p>
        <p>Rating: {{ picture.rating }}</p>
    </div>//if return object, should follow this HTML format type
</div> 

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

How can you update the property values of a CSS class that already exists in an Angular2+ controller?

In my styles.css file, I have a CSS class called '.users' with a property of color. Now, I am looking to dynamically change the color property value of the 'users' class based on certain conditions in my controller. For instance, I want ...

Whenever a file is chosen, I aim to generate the video HTML dynamically and display the video with play functionalities using Angular 2 and TypeScript

I am attempting to allow users to select a video file and display it so they can play it after choosing the file. Below is my HTML code: <br> <input type="file" (change)="fileChangeEvent($event)" placeholder="upload file..." class=" ...

Tips for utilizing dispatch within a client class?

As I continue my journey of developing a client/wrapper using axios with Zod and Redux, I aim to create a client that can handle fetch errors and dispatch necessary state updates to Redux. After successfully implementing Zod and the validation part into t ...

Top method for allowing non-component functions to update Redux state without the need to pass store.dispatch() as a parameter

As I work on my first ReactJS/redux project, I find myself in need of some assistance. I've developed a generic apiFetch<T>(method, params) : Promise<T> function located in api/apiClient.ts. (Although not a React component, it is indirect ...

Using an Angular library module to inject the same service instance of an abstract class

Currently, I am in the process of developing a library and sample application using Angular 11. One specific requirement is to enable the consuming application to inject an implementation of a base class into the library. Within the library, I have already ...

Validating Angular input for decimal values based on specific criteria

Is there a way to limit user input to numbers with only 2 decimal places if both itemNew.UL_DATA and itemNew.LL_DATA are equal to 0 or blank? <ion-col col-2> <input (keypress)="ShowKey();" [style.display]="itemNew.UL_DATA== ...

Enhance User Experience in IE11 by Providing Font Size Customization with Angular (Using CSS Variables)

I am in the process of developing an Angular application. One of the requirements is to allow the user to choose between small, medium, or large font sizes (with medium being the default) and adjust the font size across the entire webpage accordingly. Wh ...

Implementing the react-i18next withNamespaces feature in Ant Design forms

I'm a newcomer to i18next and TypeScript, and I'm trying to translate an antd form using withNamespaces. export default withNamespaces()(Form.create()(MyComponent)); Encountering the following error: Argument of type 'ComponentClass< ...

Why aren't all client perspectives updated when I delete documents from the collection?

Currently, I am utilizing Angular2-meteor which is running on Angular2 Beta 1. Within my simple component, I have: A button to add a document. Once added, the document can be removed by its _id using another button. Additionally, there is a "Remove All" ...

React Navigation with TypeScript: The specified type is incompatible with the 'BottomTabNavigatorConfig' parameter

I'm currently in the process of developing a mobile app using React Native and I've chosen to manage my navigation with React Navigation V2. Recently, I came across some code on the official documentation that seemed perfect for what I needed: ...

Tips on personalizing the formatting alert in Webclipse for Angular 2 using Typescript

Webclipse offers extensive formatting warnings for TypeScript code, such as detecting blank spaces and suggesting the use of single quotes over double quotes. However, some users find the recommendation to use single quotes annoying, as using double quotes ...

Using Standardized Props in TypeScript for Type Validation

My goal is to create a component that can receive other components and their props, while also injecting custom props. type InjectProps<P> = { custom: string } & P interface Props<P> { component: React.ComponentType<InjectProps< ...

Tips for transferring several parameters from an Angular 8 application to a .NET Core API

Hello, I am facing an issue with passing multiple string parameters from an Angular 8 app to a .NET Core API. This is my first time posting a question so I will try to provide all the necessary details. Here is the Angular code snippet: import { Injectab ...

Unexpected error with service providers in Ionic 2 and Angular 2 using Typescript

When attempting to run my Ionic2 app in Typescript, I encountered the following error: ORIGINAL EXCEPTION: No provider for User! (BeerSearch -> User) Here is the relevant code snippet: #providers/beer_search/BeerSearch import { User } from '../u ...

Using TypeScript with Vue and Pinia to access the store

Is it necessary to type the Store when importing it to TypeScript in a Pinia Vue project? // Component <p>{{ storeForm.firstName }}</p> // receiving an error "Property 'storeForm' does not exist on type" // Store ...

Fetching Data Using Asynchronous API Calls

My goal is to retrieve all results consistently from the API, but I am encountering varying outcomes. The for loop seems to be skipping some requests and returning a random number of records. Can anyone provide assistance? I have experimented with using t ...

Leverage the component's recursive capabilities to build a tree structure from within

Is it feasible to use a component within itself? If so, where can I find more information on this? I am facing the following scenario: I have a list of main items, each main item has a subitem (which looks like the main item), and each subitem can have i ...

Strategies for setting the output value for a defined generic type

Is there a way to create a function that accepts optional properties common across different types, while also requiring specific properties based on the generic type passed in? type Diff<T, U> = T extends U ? never : T type DiffTypes<T, U> = ...

issue encountered while trying to resolve dependency tree during npm installation: ERESOLVE - unable to

I encountered an issue while attempting to run npm install, and received the following error message. npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: <a href="/cdn-cgi/l/email-protection" ...

Steps to deactivate a list of dates within the <ion-datetime> element in Ionic 4

Is there a way to disable specific dates in ion-datetime without disabling the entire date component? I have tried using the disabled-value but it seems to disable all dates. Any suggestions on how to achieve this? <ion-datetime displayFormat="MM/DD/ ...