将diese用作字符,而不是像yml文件中的注释一样

时间:2014-12-17 15:04:44

标签: angularjs symfony

我尝试声明一个使用angular的路由,在我的security.yml中进行身份验证后我会重定向到#/ welcome但是认为它是一个评论

default_target_path: #/welcome

我的app.js

routeApp.config(['$routeProvider',function($routeProvider) { 
// Routing system
    $routeProvider
    .when('/login', {
        templateUrl: Routing.generate('login'),
        controller: 'SecurityController'
    })
    .when('/welcome', {
        templateUrl: Routing.generate('ard_backend_test'),
        controller: 'WelcomeController'
    })
    .otherwise({
        redirectTo: '/login'
    });
}]);

1 个答案:

答案 0 :(得分:0)

只需为字符串添加双引号,哈希#字符就能逃脱。

default_target_path: "#/welcome"

更新:不要在yml配置中定义默认客户端路由。 这应该是角度路由器配置的一部分。取决于您使用的路由器。

以下是角度为default routeService的示例:

angular.module('MyApp', ['ngRoute'])
       .config(['$routeProvider', function($routeProvider) {
    $routeProvider.
      when('/welcome', {
        templateUrl: 'partials/welcome.tpl.html',
        controller: 'WelcomeCtrl'
      }).
      when('/some-other-route', {
        templateUrl: 'partials/some-other-route.tpl.html',
        controller: 'SomeOtherCtrl'
      }).
      otherwise({
        redirectTo: '/welcome'
      });
  }]);