gpt4 book ai didi

javascript - 通过开放模态函数 Angular uibModal 传递数据

转载 作者:可可西里 更新时间:2023-11-01 01:46:07 25 4
gpt4 key购买 nike

我正在尝试弄清楚如何在弹出时将 unit_number 传递到模式中。我是 Angular 的新手,我对 resolve:group: 正在做的事情以及如何在返回语句中包含 unit_number 感到有点困惑。

    $scope.openTenantModal = function (unit_number) {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'views/addtenantmodal.html',
controller: 'AddTenantModalCtrl',
size: 'large',
resolve: {
group: function () {
return $scope.group;
}
}
});
modalInstance.result.then(function () {
}, function () {
});
};

最佳答案

你正在使用 ui-bootstrap

Bootstrap components written in pure AngularJS

要将变量传递给您需要使用的模态 Controller

resolve: {
A: function() {
return 'myVal'
}
}

然后您可以通过注入(inject)从模态 Controller 访问变量“A”

controller: ['A', function(A) {
// now we can add the value to the scope and use it as we please...
$scope.myVal = A;
}]

checkout :https://angular-ui.github.io/bootstrap/#/modal

解决:

Members that will be resolved and passed to the controller as locals; it is equivalent of the resolve property in the router.

组只是一个成员(它可以是你选择的任何东西)

关于javascript - 通过开放模态函数 Angular uibModal 传递数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38311159/

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