Skip to content
This repository has been archived by the owner on Oct 11, 2019. It is now read-only.

Latest commit

 

History

History
129 lines (97 loc) · 2.35 KB

pratico.md

File metadata and controls

129 lines (97 loc) · 2.35 KB

Prático

1) Adicione o método .last() na classe Array, que retornará o último item do array, ou undefined caso o array estiver vazio

// Resposta


// Teste/Exemplos
const array1 = [1,2,3,4,5,6,7,8,9]
console.log(array1.last()) //9

const array2 = []
console.log(array2.last()) //undefined

2) Melhore a função a seguir:

function getTransactions() {
    return $q((resolve, reject) => {
        $http.get(BASE_URL + '/api/transacoes')
            .then(response => {
                if (!response.data.error) {
                    const transactions = response.data

                    var _transactions = []

                    for (var i in transactions) {
                        if (transactions[i].realizada)  {
                            _transactions.push({
                                id: transactions[i].id,
                                value: transactions[i].valor,
                                type: transactions[i].valor < 0 ? 'transference' : 'deposit',
                            })
                        }
                    }

                    resolve(_transactions)
                } else {
                    reject(response.data.error)
                }
            })
            .catch(e => reject(e))
    })
}
// Resposta

3) Identifique problemas nos trechos de html/angular a seguir e corrija:

3.1)

<img src="{{item.img}}">

[Problemas]

<!-- correção -->

3.2)

...
<body ng-controller="PageCtrl">
    <h1>{{page.mainTitle}}</h1>
    ...
</body>

[Problemas]

<!-- correção -->

3.3)

...
<body ng-controller="NewsletterCtrl">
    <div class="box">
        <p>Cadastre-se na nossa news semanal!</p>
        <input ng-model="email" type="email">
        <button ng-click="email && registerNewsletter(email)">
            Cadastrar
        </button>
    </div>
    ...
</body>

[Problemas]

<!-- correção -->

3.4)

function HomeCtrl($scope) {
    $scope.foo = 'bar'
}

[Problemas]

//correção

4) Na pasta src, crie uma aplicação web:

4.1) Buscar os dados do endpoint: https://5ba412108da2f20014654cf8.mockapi.io/api/v1/flights

4.2) Implementar a listagem de voos (tela "My bookings"):

Layout