2016-08-16 3 views
0

문제 : meanjs 애플리케이션의 목록 데이터를 편집하는 모달 화면이 있습니다. CRUD 작업에 요 발생기를 사용했습니다. 편집보기에는 컨트롤러 폴더에 별도의 파일이있는 별도의 컨트롤러가있는 모달이 있습니다.평균 UI 모달 컨트롤러 팝업

저는 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> 

//

(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; 
     } 
    } 
    } 
})(); 
+0

콘솔 오류가 있습니까? – Nitish

+0

안녕하세요. edit.html에서 data-ng-controller

를 제거합니다. 콘솔 오류가 없으며 팝업이 나타나지 않습니다.>
를 그대로두면 다음과 같이 표시됩니다 : 'angular.js : 11706 오류 : [$ injector : unpr] 알 수없는 공급자 : customerResolveProvider <- customerResolve <- CustomersController' –

답변

0

가 동일하게 모달 논리와 종속성을 이동 customers.client.controller.js 컨트롤러 (이 경우 list-customers.client.controller.js)에서 호출됩니다.

data-ng-controller= "CustomersController as customersCtrl" 종속성 중 하나에 routes.js 파일에서만 사용할 수있는 해결 기능이 필요하기 때문에 data-ng-controller= "CustomersController as customersCtrl"을 사용할 수 없습니다.