question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

text.replace is not a function error when use [ngOptionHighlight]="search"

See original GitHub issue

I am using ng-select with dynamic items (load items from API). Items, which I receive is just an array of objects that have only 3 properties: Id, Name, Group. BindValue and BindLabel set to Name property. Name contains values in Russian language

This is the code, which I use to ng-select dropdown list:

<ng-select [items]="fastSearchResult"
        [multiple]="true" [(ngModel)]="fastSearchObj.search" (search)='fastSearchChanged($event)'
        groupBy="group" bindLabel="Name" bindValue="Name"
        class="form-control keyword"
        placeholder="Быстрый поиск вуза, спец-ти ">
    <ng-template ng-optgroup-tmp let-item="item">
          <div>{{ item.group }}</div>
     </ng-template>
      <ng-template ng-option-tmp let-item="item">
           <div [ngOptionHighlight]="search" class="fs-13 ml-1 lh-20">{{ item.Name }}</div>
       </ng-template>
</ng-select>

Be aware that I use Subjects to trigger a moment when a user stopped typing and send a request to API Each time when ng-select receives a result it shows an error:

text.replace is not a function at stripSpecialChars (ng-select.js:1056)

Inside of this function:

function stripSpecialChars(text) {
    /** @type {?} */
    var match = function (a) {
        return diacritics[a] || a;
    };
    return text.replace(/[^\u0000-\u007E]/g, match);
}

Could you please advise what i need to do to resolve the issue? Can the Russian language be a problem? It used to work in AngularJS

Many thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Khokhlachovcommented, Jun 11, 2019

@Denis-Evseev your “group” in groupBy="group" is numbers and error in https://www.screencast.com/t/Jk3tJCk2 need map your “group” value to string

0reactions
ComsatArchitectscommented, Apr 2, 2019

To reproduce - have a ng-select that is not searchable, but type a letter anyway when it’s open.

I typed “d” and the first time through it called function stripSpecialChars(‘d’) on line 1064 of ng-select.js

The function ran again but for some reason it called stripSpecialChars(false) and it threw the error, not knowing how to deal with “false” as an input.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: replace is not a function in JavaScript | bobbyhadz
The "replace is not a function" error occurs when we call the replace() method on a value that is not of type string...
Read more >
var.replace is not a function - javascript - Stack Overflow
I'm using the below code to try to trim the string in Javascript but am getting the error mentioned in ...
Read more >
the 'options.text.replace is not a function' error occurs after ...
Hi, After upgrading from 1.9 to 2.3, I got the error message. By tracing, it comes down to the following statement/condition that was...
Read more >
Content.replace is not a function (Example) - Treehouse
So, the values never end up begin replaced when I render the page on the browser. I get an error in the replace...
Read more >
Solved: "replaceAll is not a function" JavaScript TypeError
How to Fix "replaceAll is not a function" JavaScript Error? ... replaceAll() , you may use the String.prototype.replace() method with a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found