我想我的控制器傳遞到另一個控制器和我不斷收到一個錯誤:[$注射器:unpr]未知提供商:MchControllerProvider < - MchController傳遞到控制器控制器在Javascript
如何正確注入一個控制器到另一個?這裏是我的代碼:
這一部分是GroupMaintenanceBrowsePlansCtrl->
(function() {
'use strict';
var controllerId = 'GroupMaintenanceBrowsePlansCtrl';
angular.module('myApp').controller(controllerId, ['$scope', 'RenewalGroupDataService', 'logger', 'mchService', 'MchController' , Controller]);
function Controller($scope, datacontext, logger,mchService, MchController) {
logger = logger.forSource(controllerId);
....
這一部分是MchController - >
'use strict';
myApp.controller('MchController', function ($scope, $routeParams, mchService, CustomerDataService, EntityInfoService, RatesDataService, RenewalGroupDataService) {
console.log('reached MchController');
//Rout parameters as passed via App.js
$scope.routeParams = {
type: $routeParams.Type,
id: $routeParams.Id
};
//Properties associated with data
$scope.visible = {
experience: true,
persistency: true,
}
// define view model and expose it to the scope
var vm = {
title: 'Loading MCH Name... ',
CustomerNumber: 'Loading MCH Number...'
};
$scope.vm = vm; //local scope to MchController
vm.type = $routeParams.Type;
vm.id = $routeParams.Id;
vm.togglePlans = togglePlans;
vm.toggleRates = toggleRates;
vm.getRateInformation = getRateInformation;
vm.getMch6 = getMch6;
vm.Mch2Information = [];
vm.searchParameters = mchService.searchParameters;
function togglePlans()
{
vm.expandedPlans = !vm.expandedPlans;
}
//Puts multiple sets of Mch2 data into array to iterate through
vm.Mch2Information = new Array();
vm.getEntityInformation = function() {
getEntityInformation('MCH', mchService.searchParameters);
}
//Initialize GET command for Customer Information
//getEntityInformation($routeParams.Type, $routeParams.Id);
function getEntityInformation(type, id)
{
switch (type)
{
case "MCH": getCustomerInformation(id);
//getMch6();
getMch2Information(id);
....
驗證包含MCHController定義的文件包含在您的index.html。 – 2014-09-29 16:14:45
我驗證了它在index.html – user1789573 2014-09-29 16:59:59