0
問題:我有一個模式屏幕來編輯應用程序中的列表數據。我使用喲發電機進行CRUD操作。在編輯視圖中,我有一個模式,它有一個單獨的控制器,我在控制器文件夾中有一個單獨的文件。Meanjs中的角度用戶界面模態控制器彈出
我是新的angularjs 1.我無法得到模式彈出。我的代碼中是否有錯誤?
我在控制檯中得到了以下錯誤。
angular.js:11706 Error: [$injector:unpr] Unknown provider: customerResolveProvider <- customerResolve <- CustomersController
//列表customer.client.view.html
<section data-ng-controller= "CustomersController as customersCtrl">
<div class="page-header">
<h1>Customers</h1>
</div>
<!--Search bar-->
<div class="col-xs-12 col-sm-8">
<div class="input-group input-group-lg">
<input type="text" class="form-control" placeholder="Search for..." ng-model="searchText">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div><!-- /input-group -->
</div>
<div class="row">
<div class="col-xs-12 col-sm-4 text-center">
<button type="button" class="btn btn-success text-center">
<i class="glyphicon glyphicon-user"></i><br>
New Customer
</button>
</div>
</div>
<div class="list-group">
<div class="col-xs-6 col-sm-4" data-ng-repeat="customer in vm.customers | filter:searchText">
<a ng-click="customersCtrl.modalUpdate('lg', customer)"
class="list-group-item">
<h4 class="cust-list text-center">
<i class="glyphicon glyphicon-user"></i>
</h4>
<div class="row">
<div class="col-xs-10 col-xs-offset-1">
<h4>{{customer.firstName}} {{customer.lastName}}</h4>
<small class="list-group-item-text text-muted">
<span data-ng-bind="customer.created | date:'mediumDate'"></span>
</small>
</div>
</div>
</a>
</div>
<div class="alert alert-warning text-center" data-ng-if="vm.customers.$resolved && !vm.customers.length">
No Customers yet, why don't you <a data-ui-sref="customers.create">create one</a>?
</div>
<!--<small class="list-group-item-text">-->
<!-- {{customer.firstName}}-->
<!-- Posted on-->
<!-- <span data-ng-bind="customer.created | date:'mediumDate'"></span>-->
<!-- by-->
<!-- <span data-ng-if="customer.user" data-ng-bind="customer.user.displayName"></span>-->
<!-- <span data-ng-if="!customer.user">Deleted User</span>-->
<!--</small>-->
</section>
// customers.client.controller.js
(function() {
'use strict';
// Customers controller
angular
.module('customers')
.controller('CustomersController', CustomersController);
CustomersController.$inject = ['$scope', '$state', 'Authentication', 'customerResolve', '$uibModal', '$log'];
function CustomersController ($scope, $state, Authentication, customer, $uibModal, $log) {
// serialize forms
var vm = this;
vm.authentication = Authentication;
vm.customer = customer;
vm.error = null;
vm.form = {};
vm.remove = remove;
vm.save = save;
// vm.customers = customer.query();
// Open a modal window to update a single customer record
this.modalUpdate = function (size, selectedCustomer) {
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'modules/customers/client/views/form-customer.client.view.html',
controller: function ($scope, $uibModalInstance, customer) {
$scope.customer = customer;
},
size: size,
resolve: {
items: function() {
return $scope.selectedCustomer;
}
}
});
modalInstance.result.then(function (selectedItem) {
$scope.selected = selectedItem;
}, function() {
$log.info('Modal dismissed at: ' + new Date());
});
};
// Remove existing Customer
function remove() {
if (confirm('Are you sure you want to delete?')) {
vm.customer.$remove($state.go('customers.list'));
}
}
// Save Customer
function save(isValid) {
if (!isValid) {
$scope.$broadcast('show-errors-check-validity', 'vm.form.customerForm');
return false;
}
// TODO: move create/update logic to service
if (vm.customer._id) {
vm.customer.$update(successCallback, errorCallback);
} else {
vm.customer.$save(successCallback, errorCallback);
}
function successCallback(res) {
$state.go('customers.view', {
customerId: res._id
});
}
function errorCallback(res) {
vm.error = res.data.message;
}
}
}
})();
你有任何控制檯錯誤? – Nitish
嗨。在edit.html下,如果我刪除了data-ng-controller。它不會有任何控制檯錯誤,彈出窗口不會出現> 如果我離開,它會給我這個: 'angular.js:11706錯誤:[$ injector:unpr]未知提供者:customerResolveProvider < - customerResolve < - CustomersController' –