Angular - type 'string' is not assignable to type 'boolean' - Solved
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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Angular Server Side Pagination Tutorial
- Angular Material Multi Select Dropdown with Chips Example
- Angular Material Select Dropdown with Image Example
- Angular Ngclass with Ternary Operator Example
- Solved - object is possibly 'null angular reactive form validation
- Angular Google Pie Chart Example
- Angular Owl Carousel/Slider Example Tutorial
- Angular Input Change Event Example
- Angular Show Error Message on Submit Example
- How to Install And Use JQuery in Angular?
- How to Redirect to Another Page in Angular?