I have integrated a third-party library called intl-tel-input into my project.
1- Start by installing jQuery:
npm install --save jquery
Next, import jquery
into any of your app files like so:
import $ from "jquery";
You can now use it as follows:
$('#elemId').width();
2- Install the intl-tel-input library:
npm install intl-tel-input --save
Similarly, import intl-tel-input
into your app files:
import 'intl-tel-input';
And use it in your code as shown below:
ngOnInit(): any {
let telInput = $("#elemtId");
let output = $("#output");
telInput.intlTelInput();
telInput.on("keyup change", function() {
var intlNumber = telInput.intlTelInput("getNumber");
if (intlNumber) {
output.text("International: " + intlNumber);
} else {
output.text("Please enter a number below");
}
});
}
home.html
<p id="output">Please enter a number below</p>
<input id="elemtId" type="tel">
ionic info
Your system details:
Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.12
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.45
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: OS X El Capitan
Node Version: v5.12.0
Xcode version: Xcode 7.3 Build version 7D175