0

我来自服务器,在 Laravel 框架中,我们有一个“环境”的概念。

有一个paths.php文件,你可以像这样定义一个数组:

$environments = [
    'local' => ['*.dev', 'http://localhost/*'],
    'staging' => ['staging.url.com']
]

然后可以在子文件夹'local'和'staging'中制作相应的配置文件,并从那里提取数据库设置等内容。

我为什么要这个?

我想根据我所在的位置自动检测要使用的基本 URL:

angular
.module('myApp.services', [])
.value('homeURL', 'http://local.dev')
//.value('homeURL', 'http://server.com');

然后我可以继续{{ homeURL }}在应用程序的各种视图等中使用,现在,我在推送到服务器之前注释/取消注释适当的行,但如果有更简单的方法会很好......

4

1 回答 1

0

我发现我可以改用 angular $location.host(),这完全符合我的需求。

于 2013-05-25T06:13:55.353 回答