您可以尝试这样
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);
});