gpt4 book ai didi

javascript - ModalInstanceCtrl 给出此错误的最常见原因是什么?

转载 作者:行者123 更新时间:2023-11-30 16:51:52 24 4
gpt4 key购买 nike

我正在尝试连接一个 Angular Bootstrap 模式(弹出窗口),但它给了我“templateUrl”未找到错误,或者这个错误:错误:[ng:areq] http://errors.angularjs.org/1.3.15/ng/areq?p0=ModalInstanceCtrl&p1=not%20a%20function%2C%20got%20undefined

我只是想要一些关于为什么会这样的理论建议。我已经尝试了很多事情:一切都正确连接,所有拼写匹配等等。

$modal 也在 Controller 中与其他函数一起使用,所以它都被注入(inject)了。

最佳答案

Angular 文档提供了一个建议,当您收到此错误时,您可能有一个 Controller 被注入(inject)到另一个 Controller 中。这正是我尝试添加模态作为他们的盒子解决方案时发生的事情:

angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function ($scope, $modal, $log) {

$scope.items = ['item1', 'item2', 'item3'];

$scope.animationsEnabled = true;

$scope.open = function (size) {

var modalInstance = $modal.open({
animation: $scope.animationsEnabled,
templateUrl: 'myModalContent.html',
controller: 'ModalInstanceCtrl',
size: size,
resolve: {
items: function () {
return $scope.items;
}
}
});

modalInstance.result.then(function (selectedItem) {
$scope.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
};

$scope.toggleAnimation = function () {
$scope.animationsEnabled = !$scope.animationsEnabled;
};

});

controller: 'ModalInstanceCtrl' 如果您要将它添加到现有 Controller ,则必须从模态函数中删除,否则它将全部转到...您知道在哪里。

关于javascript - ModalInstanceCtrl 给出此错误的最常见原因是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30409071/

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