gpt4 book ai didi

javascript - 通过点击传递数据以加载模态

转载 作者:行者123 更新时间:2023-11-27 23:19:19 25 4
gpt4 key购买 nike

我如何从加载模态的调用中传递数据,即这个 var c ,以便我可以在我的 Controller 上使用它来在我的查询中使用它

$scope.compareMe = function(Data) {
console.log($scope.cannedLst.name)
var c = $scope.cannedLst.name;
$scope.Data = c;
$scope.modal.show();
}

最佳答案

在使用您的 Controller 中$ionicModal您可以将数据作为范围变量传递

//your main controller
.controller('MyController', function($scope, $ionicModal) {

//you function to get data and call modal
$scope.compareMe = function(Data) {
console.log($scope.cannedLst.name)
var c = $scope.cannedLst.name;
//this is the data we're passing
$scope.Data = c;
$scope.modal.show();
}

//modal configuration (may be 'templateString')
$ionicModal.fromTemplateUrl('my-modal.html', {
//here it states that inside the modal $scope will be == data you've passed
scope: $scope.Data,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
});

关于javascript - 通过点击传递数据以加载模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35524490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com