N
N
Nikita Azarchenkov2017-04-16 04:35:12
C++ / C#
Nikita Azarchenkov, 2017-04-16 04:35:12

How does server work work when using Angularjs?

When using Angularjs, the application consists of three main parts, the Model View and the Controller. The model displays the data, and the controller displays all the application logic. The controller is written in a js file that is executed in the browser and, if necessary, requests data from the server. It turns out that the entire site engine works for the client. Did I understand it correctly? But what about the server part of the application written in php or java? How is data exchanged between the application and the database?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
T
Therapyx, 2018-04-17
@Therapyx

No way, you allocate static memory for 1000 elements of type "x". If you use third-party libraries, it only gives the appearance that such an operation is done in 1 line. To then move subsequent elements back, you need to iterate the entire array. To make it 1 less, you need to allocate a new memory instance for this array and copy the old elements into it.
Choosing a data structure - think before you have to work with it, if you need it in a dynamic version, then it's better to use vector.

std::vector<int> array;
array.erase(array.begin() + 400);

Although here, in fact, the same thing happens that I described above. But there are corresponding methods in the STL for this.

T
tsarevfs, 2018-04-17
@tsarevfs

int a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
auto iterToRemove = std::next(a, 4);
std::copy(std::next(iterToRemove), std::end(a), iterToRemove);

UPD:
You need to understand that since we do not reduce the size, there will be "garbage" at the end of the array, namely a copy of the last element.

A
anikavoi, 2018-04-18
@anikavoi

memcpy will "shift". There is also a cycle, but "inside".
You, judging by the question, do not understand how an array works - it's just a memory area.
You can delete an element in a std::vector.
For example:
std::vector myarr;
myarr.push_back(0);
myarr.push_back(1);
myarr.push_back(2);
myarr.push_back(3);
myarr.push_back(4);
myarr.erase(myarr.begin()+2);
for(int n : myarr)
{
printf("%d\n",n);
}
0
1
3
4

A
Alexander Manakov, 2017-04-16
@gogolor

Through Ajax. Angular 1 has a wrapper over it - $http vervis

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question