Php Nette框架-返回一个Angular 2应用程序
我正在使用Nette framework在后端创建一个应用程序,对于前端,我希望使用基于Angular 2 framework构建的应用程序Php Nette框架-返回一个Angular 2应用程序,php,angular,nette,Php,Angular,Nette,我正在使用Nette framework在后端创建一个应用程序,对于前端,我希望使用基于Angular 2 framework构建的应用程序 因此,在我的解决方案中,我需要从后端的Nette向用户发送基于Angular 2的应用程序。如何使用Nette提供此应用程序?假设在访问您的页面(例如-myapp.com)后,请求立即转到主页演示者 路由 如果您还没有,请在您的RouterFactory中设置此路由(通常在/app/RouterFactory.php中) 主页演示者 /app/presen
因此,在我的解决方案中,我需要从后端的Nette向用户发送基于Angular 2的应用程序。如何使用Nette提供此应用程序?假设在访问您的页面(例如-myapp.com)后,请求立即转到主页演示者 路由 如果您还没有,请在您的RouterFactory中设置此路由(通常在/app/RouterFactory.php中) 主页演示者 /app/presenters/HomepagePresenter.php 这是我们需要返回的模板。将/dist文件夹放入Nette中的public/www文件夹,也可以将其重命名为/myapp frontend 这些都可以在以后自动完成 模板 /app/presenters/templates//@layout.latte
myapp.com
{块样式}{/block}
window.module='aot';
$router[] = new Route('/', 'Homepage:default');
<?php
namespace App\Presenters;
use Nette;
use Latte\Engine;
use Nette\Bridges\ApplicationLatte\Template;
class HomepagePresenter extends BasePresenter {
public function renderDefault() {
$this->setView('angular2App');
}
}
/dist
├───src
│ └───app.min.js
├───styles
│ ├───app.css
│ └───vendor.css
└───index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<base href="/" />
<title>myapp.com</title>
{block styles}{/block}
<script>window.module = 'aot';</script>
</head>
<body>
<div class="page">
<app>For full functionality of this app, please enable Javascript in your browser.</app>
</div>
{block scripts}{/block}
</body>
</html>
{block styles}
<link href="/myapp-frontend/styles/vendor.css" rel="stylesheet" />
<link href="/myapp-frontend/styles/app.css" rel="stylesheet" />
{/block}
{block scripts}
<script src="/myapp-frontend/src/app.min.js" async defer></script>
{/block}