gpt4 book ai didi

javascript - Angular js 中未定义 modalInstance

转载 作者:行者123 更新时间:2023-12-03 03:18:48 25 4
gpt4 key购买 nike

ModalInstance 数据在导入 Controller 时变为 NULL。我也更改了 modelInstance 名称。但没有成功。这里添加我的代码,

SaveController.js

scope.open = function (_data) {   //data is present 
var modalInstanceData = modal.open({
controller: "PopUpController",
templateUrl: 'myModalContent.html',
resolve: {
data: function()
{
return _data; // values are present here
}
}
});

};

PopUpController.js

angular.module('user').controller('PopUpController',
['$scope','$state','$uibModalInstance',
function(scope,state,modalInstanceData,data) {

data={};
scope.data = data;
farmBid.produceValue = scope.data.produceId; //value is present here

}])

HTML

<script type="text/ng-template" id="myModalContent.html">

<div class="modal-body">
<input type="text" name="produceValue" ng-model="farmBid.produceValue" />

<!-- But here its not prefilling the data-->

<input type="submit" ng-click="generate(farmBid)">
</div>
</script>

Modal data values are not being visible in HTML page

请帮忙

最佳答案

您应该以正确的顺序传递参数并且应该匹配,您缺少'data'

angular.module('user').controller('PopUpController',
['$scope','$state','$uibModalInstance','data',
function(scope,state,modalInstanceData,data) {

关于javascript - Angular js 中未定义 modalInstance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46660636/

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