javascript - AngularJS modal iframe get form values -
i have angularjs project open modal window. in modalwindow have iframe wich loads external url. external url has form.
is there way access formvalues without using jquery?
so i've got modal called controller:
var modalinstance = $modal.open({ templateurl : 'modal.html', controller : 'modalcontroller', size : "lg", resolve: { options: function () { return { iframeurl : “http://www.myexternalurl", }; } } });
modal.html
<div class="modal-dialog"> <iframe ng-src="{{options.iframeurl}}" id="myiframe" sandbox="allow-same-origin allow-scripts" class="modaliframe" seamless='seamless' style="border:0" frameborder="0"></iframe> </div>
modal controller
.controller('modalcontroller' , ['$scope', '$modalinstance' , '$sce' , 'options' , '$document' , function($scope, $modalinstance , $sce , options , $document) { $scope.options = null; if(options) { $scope.options = options; if($scope.options.iframeurl) { $scope.options.iframeurl = $sce.trustasresourceurl($scope.options.iframeurl); $modalinstance.rendered.then(function(){ var myelement = angular.element($document[0].queryselector('#myiframe')); console.log(myelement); console.log(myelement.find("form")); }); } } }]);
form on external url
<form id="myform"> <input type='text' name='test'> </form>
so modal controller need access form (loaded in iframe) , values input named test
Comments
Post a Comment