M
M
magary42015-05-15 15:01:29
PHP
magary4, 2015-05-15 15:01:29

How to make a hybrid of SPA and classics?

before the advent of angular, projects looked like this

$app->get('/', function () {
    ......
});
$app->get('/auth', function () {
    ......
});
$app->get('/admin', function () {
    ......
});
$app->get('/admin/orders', function () {
    ......
});
$app->get('/admin/users', function () {
    ......
});
$app->run();

the user wandered around the site and the server gave the desired view
with the advent of angular, the entire front-end began to work without overload.
$app->get('/', function () {
    exit(file_get_contents('/ng-application/front/index.html'))
});
$app->get('/admin/orders', function () {
    exit(file_get_contents('/ng-application/admin/orders/index.html'))
});
$app->get('/admin/users', function () {
    exit(file_get_contents('/ng-application/admin/users/index.html'))
});

how correct is this approach?
those. the server gives, depending on the request, different ng-applications in which there are already "small routes"
orders.html#/index
orders.html#/create
orders.html#/update
how do you implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2015-05-15
Protko @Fesor

on a REST server, the client knows nothing about the server except that REST is there. That is, no html on the server. everything on the client. From the server spits json-nom.

I
index0h, 2015-05-15
@index0h

catberry.org

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question