Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

Erro em ListaNegociacoes

Após add S{} para criar os trs, começou a dar erro no meu listaNegociacoes, alertando isso aqui no get negociações : " [].concat is not a function "

4 respostas

Sem o código fica difícil ajudar. Poste seu código para que eu possa verificar.

LISTA NEGOCIACOES:

class ListaNegociacoes {

    constructor(){
        this._negociacoes = [];
    }

    adiciona(negociacao){
        this._negociacoes.push(negociacao);
    }

    get negociacoes(){

        return [].concact(this._negociacoes);
        return this._negociacoes;
    }
}

NEGOCIACOES VIEW

class NegociacoesView {

    constructor(elemento){
        this._elemento = elemento;
    }

    _template(model){

        return `
        <table class="table table-hover table-bordered">
            <thewad>
                <tr>
                    <th>DATA</th>
                    <th>QUANTIDADE</th>
                    <th>VALOR</th>
                    <th>VOLUME</th>
                </tr>
            </thead>

            <tbody>
                ${model.negociacoes.map(n => 
                     `  <tr>
                            <td>${DateHelper.dataParaTexto(n.data)}</td>
                            <td>${n.quantidade}</td>
                            <td>${n.valor}</td>
                            <td>${n.volume}</td>
                        </tr>
                    `
                    ).join('')}
            </tbody>
            <tfoot>
                <td colspan="3">
                    <td>
                    ${
                        (function () {
                            let total = 0 ;
                            model.negociacoes.forEach( n => total+=n.volume); 
                            return total;              
                        })()

                    }

                    </td>
                </td>

            </tfoot>
        </table>`;
    }

    update(model){
        this._elemento.innerHTML = this._template(model);
    }
}
solução!

Oi Renan, há um erro de digitação

return [].concact(this._negociacoes);

O correto é concat. Sucesso e bom estudo.

Poxa, era isso mesmo , muito obrigado Prof.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software