【发布时间】:2018-10-23 11:42:36
【问题描述】:
所以我是相对较新的 Angular Dart 和 Dart,我正在尝试创建一个简单的 webapp。
当我过去进行 PHP 开发时,我总是有一个配置文件来确定应用程序运行的环境,并决定以不同的方式自行设置。
我试图弄清楚如何在 Angular Dart 中实现类似的功能。特别是作为开始的示例,我想根据正在加载应用程序的 URL 设置不同的基本 href。当您阅读文档时,它说在开发过程中您应该像这样设置基本 href:
<script>
// WARNING: DO NOT set the <base href> like this in production!
// Details: https://webdev.dartlang.org/angular/guide/router
(function () {
var m = document.location.pathname.match(/^(\/[-\w]+)+\/web($|\/)/);
document.write('<base href="' + (m ? m[0] : '/') + '" />');
}());
</script>
但是为了分发它应该这样设置:
<base href="/">
所有这些都需要位于 HTML 页面的 <head> 部分,所以我想在这里做一些 if 语句。示例我将如何在 PHP 中做到这一点:
<head>
<?php if(DEV) { ?>
// Do the development base href
<?php } else if(PROD) { ?>
// Do the production base href
<?php }?>
</head>
所以我的问题基本上是,目前在 Angular Dart 中是否有可能?
【问题讨论】:
标签: dart angular-dart