N
N
Nikolai Shvetsov2016-05-11 12:32:43
Angular
Nikolai Shvetsov, 2016-05-11 12:32:43

Restangular how data update works?

recently started learning angular , started using this: https://laravel-angular.readme.io
the essence of the question is this: there is a page for adding news, and there are pages with a list of news. How to make it so that when adding news, the news list is updated without page updates.
There are 2 ways:
1) update in the component, when news is added
2) there is some kind of synchronization with the backend directly in the news list component (and it is, but I’m dumb and I don’t understand how to do all this)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nagaev, 2016-05-11
@mnagaev

// отправляем запрос на добавление новости
service.addItem(request).then(function (response) {
    // в ответ получаем добавленную новость
    // и добавляем ее к массиву новостей
    $scope.items.push(response.data);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question