Valuenormalizer as a regular function

2 posts, 0 answers
  1. Sarthak
    Sarthak avatar
    9 posts
    Member since:
    Aug 2020

    Posted 15 Sep Link to this post

    How do I replace the valuenormalizer arrow function with a regular function.whenever I try to change that getting an error.Cannot read property 'lift' of undefined.
  2. Svetlin
    Admin
    Svetlin avatar
    448 posts

    Posted 17 Sep Link to this post

    Hi Sarthak,

    Converting the following arrow function:

      public valueNormalizer = (text: Observable<string>) => text.pipe(map((text: string) => {
          return {
              value: this.listItems[this.listItems.length - 1].value + 1,
              text: text
          };
      }));

    to a regular function can be done in the following way:

      public valueNormalizer(text: Observable<string>) {
        return text.pipe(
          map((text: string) => {
            return {
              value: this.listItems[this.listItems.length - 1].value + 1,
              text: text
            };
          })
        );
      }

    Please check the following example:

    https://stackblitz.com/edit/angular-dwd3cv?file=app/app.component.ts

    I hope this helps.

    Regards,
    Svetlin
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top