如何使用ui-router?

分享人:曾健

otherwise()

和ngRoute的otherwise()函数相似,在用户提交的路径没有被定义的时候它将重定向到指定的页面。这是个创建’默认‘路径的好方法。 otherwise()只接受一个参数,要么函数要么字符串,字符串必须为合法的url路由地址,函数则会在没有任何路径被匹配的时候被运行。


                .config(function($urlRouterProvider) {
                  $urlRouterProvider.otherwise('/');
                  // or
                  $urlRouterProvider.otherwise(
                    function($injector, $location) {
                      $location.path('/');
                    });
                });
            

5.编码实战