gpt4 book ai didi

javascript - Angular : $uibModal undefined

转载 作者:搜寻专家 更新时间:2023-10-31 23:22:48 27 4
gpt4 key购买 nike

我在使用 ui.bootstrap.modal 时遇到这个错误:

Error: $uibModal is undefined

模块:

    (function(angular) {
/**
* finanziarioTerziController
*
* a controller defined in the finanziarioTerziModule and using a sample service.
*/
angular.module('finanziarioTerziModule')
.controller('finanziarioTerziController', ['$scope', 'finanziarioTerziService', function ($scope, finanziarioTerziService) {
'use strict';

$scope.elencoPatrimonioTerziCollapsed = true;
$scope.elencoPatrimonioTerzi = new Array();

$scope.products = [];

$scope.productToAdd = [];

$scope.saveProduct = function (productToAdd) {
for (var i = 0; i < productToAdd.length; i++) {
$scope.products.push(productToAdd[i]);
console.log($scope.products[i]);
}
$scope.reset();
};


$scope.reset = function () {
$scope.productToAdd.length = 0;
};

$scope.remove = function (index) {
$scope.productToAdd.splice(index, 1);
};

$scope.addProduct = function () {
$scope.productToAdd.push({
tipologia: '',
descrizione: '',
contratto: '',
ctv: '',
possesso: ''
});
};

$scope.open = function ($uibModal) {
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'finanziarioTerziSearch.html' ,
controller: 'finanziarioTerziModule',
resolve: {
items: function () {
return $scope.items;
}
}
});
};
open.$inject = '$uibModal';

finanziarioTerziService.getPatrimonioTerzi().then(function (response) {

if (response.status != '200') {
console.log('status diverso da 200');
return;
}

var elenco = response.data;

for (var i = 0; i < elenco.length; i++) {
$scope.elencoPatrimonioTerzi.push(elenco[i]);
}
});
}]);
})(angular);

模板(.html 文件)

<div class="modal-header">
<h3 class="modal-title">This is template 1</h3>
</div>
<div class="modal-body">
<ul>
<li ng-repeat="item in items">
<a href="#" ng-click="$event.preventDefault(); selected.item = item">{{ item }}</a>
</li>
</ul>
Selected: <b>{{ selected.item }}</b></div>

按钮(在另一个 Controller 内)

 <button class="btn btn-default" ng-click="open()" >Cerca Prodotto</button> 

我尝试在 Controller 中注入(inject) $uibModel,但不起作用对不起我的语言,我是意大利人

编辑:在 index.html 中

 <script src="../bower_components/jquery/dist/jquery.js"></script>
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="../bower_components/angular-route/angular-route.js"></script>
<script src="../bower_components/angular-ui-router/release/angular-ui-router.js"></script>

EDIT2:调整 ng-controller编辑 3:在 app.js 中

angular.module('patrimonioApp',['ngRoute', 'ui.bootstrap', 'ui.router',
'commonModule', 'homeModule', 'finanziarioModule', 'polizzeModule', 'finanziarioTerziModule' ])
.config(['$routeProvider', function($routeProvider) {

编辑 4:我解决了,但现在我有一个新错误

最佳答案

据我所知,您在 Controller 中注入(inject)依赖项的顺序与参数列表不匹配。请指正。

angular.module('finanziarioTerziModule')
.controller('finanziarioTerziController', ['$scope', 'finanziarioTerziService','$uibModal', function ($scope, $uibModal, finanziarioTerziService) {

$uibModal 在注入(inject)列表中排名第三,但在参数列表中排名第二。顺序应该是一样的。 PFB 正确的顺序。

angular.module('finanziarioTerziModule')
.controller('finanziarioTerziController', ['$scope', 'finanziarioTerziService','$uibModal', function ($scope, finanziarioTerziService, $uibModal) {

请更正订单并查看是否有效。我希望如此。

关于javascript - Angular : $uibModal undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37411145/

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