【问题标题】:how to avoid conflicts with angular router 1.6.x如何避免与角度路由器 1.6.x 的冲突
【发布时间】:2017-06-02 17:27:44
【问题描述】:

我在配置路由器时遇到问题。

/:lang/:country & /:lang/:country/:city 的路由器不工作。前三条路线正常,我该如何解决?

app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
    $routeProvider
    .when('/', { // works
        templateUrl : 'templates/main.html',
        controller: 'MainCtrl'
    }).when('/:lang', { // works
        templateUrl : 'templates/main.html',
        controller: 'MainCtrl'
    }).when('/:lang/premium-benefits', { // works
        templateUrl : 'templates/premium_benefits.html',
        controller: 'PremiumBenefitsCtrl'
    }).when('/:lang/:country', { // NOT working
        templateURL : 'templates/destination.html',
        controller: 'DestinationCtrl'
    }).when('/:lang/:country/:city', { // NOT working
        templateURL : 'templates/destination.html',
        controller: 'DestinationCtrl'
    }).otherwise({
        templateURL : 'main.html'
    });

    $locationProvider.html5Mode({enabled: true, requireBase: true});
}]);

【问题讨论】:

  • 你能定义“不工作”是什么意思吗?你有什么错误吗?
  • 抱歉,只是属性名称 templateURL 的拼写错误,所以它不起作用

标签: angularjs ngroute angularjs-1.6


【解决方案1】:

对不起各位,templateURL 必须是 templateUrl 哈哈

【讨论】:

    猜你喜欢
    • 2018-02-03
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多