如何访问离子框架,通过ID $ ionicModal对象元素? [英] How to access $ionicModal object elements by id in ionic framework?
问题描述
我曾经参与过不同的方式同一个问题在这里 SiganaturePad 的。现在我没有想法来处理这种情况。
我使用$ ionicModal来填充如下帆布SignaturePad。
I have posted the same question in different way here SiganaturePad.Now I dont have idea to handle this case. I am using $ionicModal to populate the SignaturePad with canvas as below.
/*SignaturePad*/
$ionicModal.fromTemplateUrl('templates/signature.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
alert('sign 1');
var canvas=angular.element("#signature-pad");
siganturePad = new SignaturePad(canvas);
alert('sign');
signaturePad.minWidth = 5;
signaturePad.maxWidth = 10;
signaturePad.penColor = "rgb(66, 133, 244)";
});
$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};
//Cleanup the modal when we're done with it!
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
// Execute action on hide modal
$scope.$on('modal.hidden', function() {
// Execute action
});
// Execute action on remove modal
$scope.$on('modal.removed', function() {
// Execute action
});
$timeout($scope.openModal, 200);
但我得到类似的错误错误:[jqLite:nosel]通过选择仰望元素不被支持jqLite见:的 http://docs.angularjs.org/api/angular.element
我可以predict我访问通过ID元素错误way.So的issue.that你可以请建议如何访问SiganaturePad初始化并访问及其子元素(清晰,保存按钮)在$ ionicModal。
I can predict the issue.that I am accessing elements via id in wrong way.So could you Please suggest How to Access the SiganaturePad to Initialize and access its subElements (clear and Save button) in $ionicModal.
推荐答案
不幸的是内置jQuery的精简版是非常有限。幸运的是,通过ID查找元素为pretty容易:
Unfortunately the built-in jQuery lite is very limiting. Luckily, looking up an element by ID is pretty easy:
而不是:
var canvas=angular.element("#signature-pad");
只是做:
var canvas=angular.element(document.getElementById("signature-pad"));
这篇关于如何访问离子框架,通过ID $ ionicModal对象元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!