在Angularjs / ionic framework

时间:2015-09-07 03:31:35

标签: angularjs ionic-framework

我有一个php投票系统,我在投票表中查看用户的IP地址,然后将新的投票插入投票表...

我的问题是如何使用angularjs在输入表单中获取客户端IP地址。

我正在使用IONIC框架为Android构建一个移动应用程序。

提前致谢。

1 个答案:

答案 0 :(得分:8)

您可以尝试这样

var json = 'http://ipv4.myexternalip.com/json';
$http.get(json).then(function(result) {
    console.log(result.data.ip)
}, function(e) {
    alert("error");
});

如果您不想使用外部服务,可以使用此cordova plugin [工作example]

喜欢这个

networkinterface.getIPAddress(function (ip) { 
    alert(ip); 
});