<script src="https://webpki.lacunasoftware.com/Scripts/LacunaWebPKI/lacuna-web-pki-1.3.3.js"></script>
<div ng-app>
<div ng-controller="ExampleController">
<form>
<button type="button" ng-click="start()">Start</button><br/>
<select ng-model="selectedCertificate" ng-options="getCertificateDisplayName(cert) for cert in certificates">
<option value="">Choose a certificate ...</option>
</select>
<button type="button" ng-click="getSelectedCert()">Get Selected Cert</button>
</form>
<p ng-repeat="log in logs">{{log.message}}</p>
</div>
</div>
JavaScript
// ------------------------------------------------------------------------------------------
// LacunaWebPKI.listCertificates example (AngularJS)
function ExampleController($scope) {
var onWebPkiDetected = function () {
log('Component detected, listing certificates ...');
pki.listCertificates().success(function (certs) {
log('Certificates listed!');
// We will assign to the $scope.certificates variable the actual array yielded
// by listCertificates and the view will call the function below to get the
// visual representation for each item.
$scope.certificates = certs;
});
};
$scope.getCertificateDisplayName = function (cert) {
// The view calls this function to get the visual representation of each
// certificate. Here, the cert variable is one of the items in the actual array
// yielded by listCertificates, so it has the properties subjectName, issuerName
// thumbprint.
return cert.subjectName + ' (issued by ' + cert.issuerName + ')';
};
$scope.getSelectedCert = function () {
if ($scope.selectedCertificate == null) {
alert('Select a certificate');
}
// The $scope.selectedCertificate contains the actual item in the array yielded
// by listCertificates. So, all we have to do is read its thumbprint property.
var selectedCertThumb = $scope.selectedCertificate.thumbprint;
alert("The selected certificate's thumbprint is " + selectedCertThumb);
};
// ------------------------------------------------------------------------------------------
// The code from this point on is necessary for the example to run, but is not the focus of
// this specific example
$scope.logs = [];
$scope.certificates = [];
$scope.selectedCertificate = null;
var myLicense = {
"format": 1,
"allowedDomains": [
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.