ItSolutionStuff.com

Angular - type 'string' is not assignable to type 'boolean' - Solved

By Hardik Savani • October 20, 2023
Angular

This post will give you example of type 'string' is not assignable to type 'boolean' angular. you will learn angular type 'string' is not assignable to type 'boolean'. I would like to share with you angular template type 'string' is not assignable to type 'boolean'. you will learn angular directive type 'string' is not assignable to type 'boolean'.

Few days ago i was working on angular pagination i need to assign "true" and "false" boolean value to tag attribute. i simply assign "true" and "false" to that attribute as like bellow:

....

<pagination-controls (pageChange)="pageChangeEvent($event)" previousLabel="Prev"

nextLabel="Next"

responsive="true"

></pagination-controls>

But i found following error:

"type 'string' is not assignable to type 'boolean'." so i must need to assign data type to that string. so i created variable on component and then i used it.

so let's see bellow solution:

Component Code:

import { Component, OnInit } from '@angular/core';

import { UsersService } from './services/users.service';

@Component({

selector: 'app-root',

templateUrl: './app.component.html',

styleUrls: ['./app.component.css']

})

export class AppComponent implements OnInit {

users:any;

p: number = 1;

total: number = 0;

zero: number = 0;

responsiveP: boolean = true;

......

View Code:

<pagination-controls (pageChange)="pageChangeEvent($event)" previousLabel="Prev"

nextLabel="Next"

(responsive)="responsiveP"

></pagination-controls>

then it works.

I hope it can help you...

Tags: Angular
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Angular Server Side Pagination Tutorial

Read Now →

Angular Material Multi Select Dropdown with Chips Example

Read Now →

Angular Material Select Dropdown with Image Example

Read Now →

Angular Ngclass with Ternary Operator Example

Read Now →

Solved - object is possibly 'null angular reactive form validation

Read Now →

Angular Google Pie Chart Example

Read Now →

Angular Owl Carousel/Slider Example Tutorial

Read Now →

Angular Input Change Event Example

Read Now →

Angular Show Error Message on Submit Example

Read Now →

How to Install And Use JQuery in Angular?

Read Now →

How to Redirect to Another Page in Angular?

Read Now →