我使用带有Symfony的棱角分明的前端.当我声明我的$routeProvider时,我必须包含我的/app_dev.PHP/因为我将html 5模式设置为true:$locationProvider.
html5Mode(true);.
$routeProvider.when('/app_dev.PHP/admin',{templateUrl: 'index.html',controller: AdminCtrl}) .when('/app_dev.PHP/admin/schedule/',{templateUrl: 'schedule.html',controller: ScheduleCtrl}) .otherwise('/app_dev.PHP/admin'); $locationProvider.html5Mode(true);
VS
$routeProvider.when('/admin',controller: AdminCtrl}) .when('/admin/schedule/',controller: ScheduleCtrl}) .otherwise('/admin'); $locationProvider.html5Mode(true);
问题是当我想使用生产环境时,我必须记住要更改这些路由.
当我进行转储以检测我正在为dev vs prod进行转储时,我有一个很好的方法可以处理这个问题,或者我是否只需要痛苦地记住改变目标环境的路径?
谢谢
解决方法
尝试使用FOSJsRoutingBundle.此捆绑包允许您在JavaScript代码中公开路由.这意味着您将能够使用给定参数生成URL,就像使用Symfony2核心中提供的Router组件一样.
https://github.com/FriendsOfSymfony/FOSJsRoutingBundle
https://github.com/FriendsOfSymfony/FOSJsRoutingBundle