如何使用 AJAX 动态更改 Select2 中的 URL? [英] How to dynamically change the URL in Select2 using AJAX?

查看:29
本文介绍了如何使用 AJAX 动态更改 Select2 中的 URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 angularjs 中使用 ui-select2 进行远程数据访问.我有一个下拉列表,根据下拉列表中选择的值,ajax 调用中存在的 URL 应该动态更改,以便我可以从该特定 URL 获取数据.

I am using ui-select2 in angularjs for remote data access. I am having a drop down, based on the value chosen in dropdown the URL present in the ajax call should change dynamically , so that I can get the data from that particular URL.

是否可以根据下拉列表中的值动态更改 URL?

Is it possible to change the URL dynamically based on the value present in the dropdown?

推荐答案

我已经使用 ajax 属性中的函数解决了这个问题:

I've resolved this problem using function in ajax property:

ajax: {
            url: function () { return '/product/' +$scope.campaign.advertiser + '/tags/'; },
            ...
}

这篇关于如何使用 AJAX 动态更改 Select2 中的 URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆