N
N
Nubbin2018-09-19 19:09:48
Angular
Nubbin, 2018-09-19 19:09:48

How to bring the first character into the class?

Angular 4, 5.
Good evening guys how to put one character in a class
Here is the text How to do this
<div class="subtitle">Привет, супер все</div>

<div class="subtitle"><span class="first">П</span>ривет, супер все.</div>

I did this in AngularJS
(function () {
    var node = $(".subtitle").contents().filter(function () { return this.nodeType == 3 }).first(),
        text = node.text().trim(),
        first = text.slice(0, 1);

    if (!node.length)
        return;

    node[0].nodeValue = text.slice(first.length);
    node.before('<span class="first">' + first + '</span>');
})();
- but on angular 4 i can't please help

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question