AngularJS: pushing new data on $ scope.myList, up

What is the right to add new content to $scope.myList = [] when I want to manipulate the DOM?

I tried $scope.myList.push(data); , which adds new data to the end and therefore to the end of the HTML template inside the ng repeater. I want him upstairs. The unshift function will reorder the array and update all elements.

New in angular.

EDIT: Perhaps the question should be this: how to add dynamic content to the top of my template?

+4
source share
1 answer

Whenever you want to add an array to an array, you will reorder the entire array. If you can dictate the data format, I suggest you add entry_number or id as the data field and use an angular filter to place new elements.

Check out this plunker .

+6
source

Source: https://habr.com/ru/post/1483954/


All Articles