This worked, thanks Lucas

On Tue, Apr 2, 2019 at 9:35 PM 'Lucas Lacroix' via Angular and AngularJS
discussion <angular@googlegroups.com> wrote:

> It's just a guess, but I think it's because the "data" array within
> collections does not have a type. Try this:
> collections = {count: 60, data: [] as any[]}
>
> Also... Stop using "var" and use "let" instead. Variables defined by "var"
> are hoisted and this can have negative effects on your code.
>
> On Tue, Apr 2, 2019 at 11:59 AM Dev C <chauhan.dev...@gmail.com> wrote:
>
>> Hello
>>
>> I have attached code in VS code which helps to generate dummy data. the
>> basic purpose of having pagination in anguar 6 project.
>>
>> this.collection.data.push(
>> {
>> id: i + 1, // here it gives error Type 'number' is not assignable to
>> type 'never'.ts(2322)
>> value: "items number " + (i + 1)
>> }
>> );
>> }
>>
>>  In above code error I slated error, the full code is at below:
>>
>> import { Component } from '@angular/core';
>> @Component({
>> selector: 'app-pagination',
>> templateUrl: './pagination.component.html',
>> styleUrls: ['./pagination.component.css']
>> })
>> export class PaginationComponent {
>> config: any;
>> collection = { count: 60, data: [] };
>> constructor() {
>> //Create dummy data
>> for (var i = 0; i < this.collection.count; i++) {
>> // var id = i +1;
>> // var value = "items number " + (i + 1)
>> this.collection.data.push(
>> {
>> id: i + 1, // here it gives error Type 'number' is not assignable to
>> type 'never'.ts(2322)
>> value: "items number " + (i + 1) // same here
>> }
>> );
>> }
>> this.config = {
>> itemsPerPage: 5,
>> currentPage: 1,
>> totalItems: this.collection.count
>> };
>> }
>> pageChanged(event: any){
>> this.config.currentPage = event;
>> }
>> }
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Angular and AngularJS discussion" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to angular+unsubscr...@googlegroups.com.
>> To post to this group, send email to angular@googlegroups.com.
>> Visit this group at https://groups.google.com/group/angular.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Lucas Lacroix
> Computer Scientist
> System Technology Division, MEDITECH <http://ehr.meditech.com>
> 781-774-2293
>
> <https://ehr.meditech.com/expanse>
>             <https://www.linkedin.com/company/meditech>
> <https://twitter.com/MEDITECH>   <https://www.facebook.com/MeditechEHR>
> Subscribe
> <https://info.meditech.com/get-great-meditech-content?hsCtaTracking=864299ec-5abf-4004-9c6d-2d051794101f%7Cc911be42-538a-4a48-8dca-a6d4001c6326>
>  to
> receive emails from MEDITECH or to change email preferences.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Angular and AngularJS discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to angular+unsubscr...@googlegroups.com.
> To post to this group, send email to angular@googlegroups.com.
> Visit this group at https://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to