我试图使用Angular.js通过applet调用java函数但没有成功.我甚至没有加载Applet(当我加载应用程序时,java控制台没有启动).我使用了以下方法但没有成功.有任何想法吗?
Binding applet parameters with angularJS
PS:它在Chrome中并启用了NPAPI.
PS2:我用Knockout用下面的代码得到它(我们正在迁移到Angular)
var res = document.getElementById("cdigApplet").signFile(file.id().toString(),"",api.token);
signFile()是Java Applet中的一个方法.
HTML:
<applet id="cdigApplet" code="cdig.CDigApplet" archive="cdig-applet-1.0.jar,cdig-0.3.jar,json-20141113.jar" width="1" height="1" classloader_cache="false"> <param name="persistState" value="false" /> <param name="cache_option" value="no"/>
谢谢.
我们用下面的代码得到它:
原文链接:https://www.f2er.com/angularjs/143485.html的index.html
<script> <!-- applet id can be used to get a reference to the applet object --> var attributes = { id:'cdigApplet',code:'cdig.CDigApplet',archive:'cdig-applet-1.0.jar,json-20141113.jar',width:1,height:1,classloader_cache:'false'} ; var parameters = {persistState: false,cache_option:'no' } ; deployJava.runApplet(attributes,parameters,'1.8'); </script>
signController.js
(function() { 'use strict'; angular .module('app') .controller('signController',signController); signController.$inject = ['$rootScope','$scope','listFactory','infoService']; /* @ngInject */ function signController($rootScope,$scope,listFactory,infoService) { var vm = this; var token = $rootScope.token; $scope.name = infoService.getName; //////////////// $scope.signFile = function () { var fileId = infoService.getId(); var Id = fileId.toString(); var res = document.getElementById("cdigApplet").signFile(Id,'',token); var json = JSON.parse(res); if (json.success === true) { alert("Documento assinado com sucesso! Clique em 'Abrir' para ver a assinatura."); $('#sign').modal('hide'); } else { alert("Documento não assinado!\n" + json.message); $('#sign').modal('hide'); } }; } })();