【问题标题】:AngularJS URL parameters to controller in array formAngularJS URL参数以数组形式传递给控制器
【发布时间】:2016-12-15 15:44:26
【问题描述】:

我想要一个网址,例如

/1234?labels=label1,label2,label3

我通过使用 routeParams 得到 1234。我知道我可以使用$location.search().labels 来获取label1, label2, label3。但是,我想检索一个数组[label1, label2, label3]。传入的标签可能多于 3 个。

app.config(function (toastrConfig, $routeProvider, $locationProvider) {
    angular.extend(toastrConfig, {
        allowHtml: true,
        timeOut: 3000,
        positionClass: 'toast-top-right',
        preventDuplicates: true,
        progressBar: true
    });

    $routeProvider
    .when('/:type/:id', {
        templateUrl: 'app/main/main.html'
    })

    $locationProvider.html5Mode(true);
});

任何帮助将不胜感激!

【问题讨论】:

    标签: angularjs url url-parameters


    【解决方案1】:

    我刚刚决定给你$location.search().labels.split(','),它有效!

    【讨论】:

      猜你喜欢
      • 2015-09-13
      • 1970-01-01
      • 1970-01-01
      • 2019-12-03
      • 1970-01-01
      • 2016-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多