任何人告诉我如何在注册页面中实现自动填充国家名称。我正在尝试通过IP和自动填充国家名称的位置,而无需在Angularjs中选择国家名称。我的控制器中的代码是
var country;
$.get("http://ip-api.com/json/", function(response) {
country=response.country;
}, "jsonp");
使用$.getJSON
代替$.get
var country;
$.getJSON("http://ip-api.com/json/",
function(res) {
country=res.country;
});