【发布时间】:2016-01-03 17:47:19
【问题描述】:
我已将div 的on-tap 值设置为打开页面控制器中定义的模式。 div 是 ng-repeat 部分的一部分。 modal 函数还接受div 传递给它的一些变量。
当应用程序在我的设备(运行 iOS 7 的 iPhone 6)上首次启动时,我必须点击 div 三次才能打开模式。之后,当我点击时它会持续打开。但是当应用第一次启动时,我必须点击 div 3 次。
控制台中完全没有错误。一旦模式打开,它就会按预期工作。
有什么建议吗?
代码如下:
HTML
<div on-tap="doModal('{{embed.ID}}','reply','{{embed.oembed}}','{{embed.user}}');">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 75 72" width="100" height="50">
<path d="imagestuffhere"/>
</svg>
</div>
控制器
$scope.doModal = function(this_ID,modaltype,this_oembed,this_user) {
$scope.contact = {
name: this_ID,
info: modaltype,
oembed: this_oembed,
user: this_user
}
if (modaltype == 'repost') {
$scope.modaltempl = 'templates/repost-modal.html';
}
else if (modaltype == 'reply') {
$scope.modaltempl = 'templates/reply-modal.html';
}
else if (modaltype == 'like') {
$scope.modaltempl = 'templates/like-modal.html';
}
else {
$scope.modaltempl = 'templates/like-modal.html';
}
$ionicModal.fromTemplateUrl($scope.modaltempl, {
scope: $scope,
animation: 'slide-in-up'
}).then(function (modal) {
$scope.modal = modal;
$scope.modal.show();
console.log($scope.modaltempl);
});
};
$scope.closeModal = function() {
$scope.modal.hide();
};
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
我尝试将$ionicModal.fromTemplateUrl($scope.modaltempl, 位拉到$scope.doModal 之外并从$scope.doModal 内部调用$scope.modal.show,但结果是一样的。
即使模式没有打开,它也肯定会到达scope.modal.show(); 语句,因为console.log 在它得到输出后我已经包含了。
在我将 svg 添加到界面之前,我使用 button 元素对此进行了测试,并且遇到了同样的问题。当我使用ng-click 而不是on-tap 时,它也有同样的问题。
感谢您的帮助!
【问题讨论】:
标签: ionic-framework ionic