使用Angular和ui-router正确处理根URL

时间:2015-08-25 22:01:04

标签: javascript angularjs angular-ui-router

我希望我的Angular网站能够使用ui-router获取多条路线,其中包括:

  • /呈现landing.html
  • /howto呈现howto.html

我尝试了以下操作,但没有成功:

$stateProvider
        .state('landing', {
            url: '/',
            templateUrl: 'views/landing.html',
            controller: 'LandingCtrl',
            data : { pageTitle: 'Landing' }
        })
        .state('howto', {
            url: '/howto',
            templateUrl: 'views/howto.html',
            controller: 'HowToCtrl',
            data : { pageTitle: 'HowTo' }
        });

我可以访问localhost/上的landing.html但无法访问/howto,我收到消息Cannot GET /howto。你有什么想法吗?

0 个答案:

没有答案