2017-01-04 19 views
0

クロムでF12キーを押したときにこのエラーが表示されますが、変なことはありません。問題はないようです。

The controller with the name 'AccountUpdateViewModel' is not registered. 

ここは私のjsファイルです。どんな考え?私が使用していますangualrのバージョンは、あなたが'AccountUpdateViewModelコントローラを持っていた1.6.0 from nuget(Iは、Visual Studio上で開発)

var accountUpdateModule = angular.module('accountUpdate', ['common', 'ngRoute']) 

    .config(function ($routeProvider, $locationProvider) { 

     $locationProvider.html5Mode({ 
      enabled: true, 
      requireBase: false 
     }); 

     $routeProvider.when(Avts.rootPath + 'account/update/step1', { templateUrl: Avts.rootPath + 'Templates/AccountUpdate/Step1.html', controller: 'AccountUpdateStep1ViewModel' }); 
     $routeProvider.when(Avts.rootPath + 'account/update/step2', { templateUrl: Avts.rootPath + 'Templates/AccountUpdate/Step2.html', controller: 'AccountUpdateStep2ViewModel' }); 
     $routeProvider.when(Avts.rootPath + 'account/update/step3', { templateUrl: Avts.rootPath + 'Templates/AccountUpdate/Step3.html', controller: 'AccountUpdateStep3ViewModel' }); 
     $routeProvider.when(Avts.rootPath + 'account/update/confirm', { templateUrl: Avts.rootPath + 'Templates/AccountUpdate/Confirm.html', controller: 'AccountUpdateConfirmViewModel' }); 
     $routeProvider.when(Avts.rootPath + 'account/update/successfullyupdated', { templateUrl: Avts.rootPath + 'Templates/AccountUpdate/Successfull.html', controller: 'AccountUpdateSuccessfullyUpdatedViewModel' }); 
     // 5:40 Sec. If it does not find any of these steps in this little spa silo, then redirect to step1 
     $routeProvider.otherwise({ redirectTo: Avts.rootPath + 'account/update/step1' }); 

    }); 



accountUpdateModule.controller("AccountUpdateViewModel", function ($scope, $http, $location, $window, viewModelHelper) { 
    // Nested ViewModels or sub viewmodels. See Video 138 3:40 Sec 
    // Things that are set up here in this view model(AccountRegisterViewModel) is bound to the priticular view Register.cshtml. 
    // see 4:50 Sec 
    $scope.viewModelHelper = viewModelHelper; 
    $scope.accountModelStep1 = new Avts.AccountUpdateModelStep1(); 
    $scope.accountModelStep2 = new Avts.AccountUpdateModelStep2(); 
    $scope.accountModelStep3 = new Avts.AccountUpdateModelStep3(); 


    $scope.fetchDataToUpdate = function() { 
     viewModelHelper.apiGet('api/account/update', null, 
      function (result) { 

       $scope.accountModelStep1.Email = result.data.Email; 
       $scope.accountModelStep1.UserName = result.data.UserName; 

       $scope.accountModelStep2.FirstName = result.data.FirstName; 
       $scope.accountModelStep2.LastName = result.data.LastName; 

       $scope.accountModelStep3.Address = result.data.Address; 
       $scope.accountModelStep3.City = result.data.City; 
       $scope.accountModelStep3.State = result.data.State; 
       $scope.accountModelStep3.PostalCode = result.data.PostalCode; 

      }); 
    } 

    $scope.fetchDataToUpdate(); 
    //$scope.previous = function() { 
    // // 6:00 Sec 
    // $window.history.back(); 
    //} 
}); 

accountUpdateModule.controller("AccountUpdateStep1ViewModel", function ($scope, $http, $location, viewModelHelper, validator) { 
    viewModelHelper.modelIsValid = true; 
    viewModelHelper.modelErrors = []; 

    // No setpup rules for step 1 edit. Just showing Email and userName 
    //var accountModelStep1Rules = []; 

    //var setupRules = function() { 

    // accountModelStep1Rules.push(new validator.PropertyRule("Email", { 
    //  required: { 
    //   message: "Email is required", 
    //   email: { message: "Email is not an email." } 
    //  } 
    // })); 
    // accountModelStep1Rules.push(new validator.PropertyRule("Password", { 
    //  required: { message: "Password is required" }, 
    //  minLength: { message: "Password must be at least 6 characters", params: 6 } 
    // })); 

     //accountModelStep1Rules.push(new validator.PropertyRule("PasswordConfirm", { 
     // required: { message: "Password confirmation is required" }, 
     // custom: { 
     //  validator: Avts.mustEqual, // See 143, 2:30 
     //  message: "Password do not match", 
     //  params: function() { return $scope.accountModelStep1.Password; } // must be function so it can be obtained on-demand 
     // } 
     //})); 
    //} 

    //$scope.fetchData = function() { 
    // viewModelHelper.apiGet('api/account/edit', null, 
    //  function (result) { 
    //   $scope.accountModelStep1.Email = result.data.Email; 
    //   $scope.accountModelStep1.UserName = result.data.UserName; 
    //  }); 
    //} 

    $scope.step2 = function() { 
     $location.path(Avts.rootPath + 'account/update/step2'); 
     // Video 144 
     // Pressing should just do validation and proceed to step 2. 
     //validator.ValidateModel($scope.accountModelStep1, accountModelStep1Rules); 
     //viewModelHelper.modelIsValid = $scope.accountModelStep1.isValid; 
     //viewModelHelper.modelErrors = $scope.accountModelStep1.errors; 
     //if (viewModelHelper.modelIsValid) { 
     // viewModelHelper.apiPost('api/account/register/validate1', $scope.accountModelStep1, 
     //  function (result) { 
     //   // See the video 144 3:35 Sec 
     //   $scope.accountModelStep1.Initialized = true; 
     //   $location.path(Avts.rootPath + 'account/edit/step2'); 
     //  }, 
     //  function (failureResult) { 
     //   $scope.accountModelStep1.errors = failureResult.data; 
     //   viewModelHelper.modelErrors = $scope.accountModelStep1.errors; 
     //   viewModelHelper.modelIsValid = false; 
     //  } 
     //  ); 
     //} 
     //else 
     // viewModelHelper.modelErrors = $scope.accountModelStep1.errors; 
    } 

    //setupRules(); 
    //$scope.fetchData(); 
}); 

accountUpdateModule.controller("AccountUpdateStep2ViewModel", function ($scope, $http, $location, viewModelHelper, validator) { 

    viewModelHelper.modelIsValid = true; 
    viewModelHelper.modelErrors = []; 

    var accountModelStep2Rules = []; 

    var setupRules = function() { 

     accountModelStep2Rules.push(new validator.PropertyRule("FirstName", { 
      required: { message: "First name is required" } 
     })); 
     accountModelStep2Rules.push(new validator.PropertyRule("LastName", { 
      required: { message: "Last name is required" } 
     })); 

    } 

    // Video 146 
    $scope.step3 = function() { 
     validator.ValidateModel($scope.accountModelStep2, accountModelStep2Rules); 
     viewModelHelper.modelIsValid = $scope.accountModelStep2.isValid; 
     viewModelHelper.modelErrors = $scope.accountModelStep2.errors; 
     if (viewModelHelper.modelIsValid) { 
      viewModelHelper.apiPost('api/account/update/validate2', $scope.accountModelStep2, 
       function (result) { 
        $scope.accountModelStep2.Initialized = true; 
        $location.path(Avts.rootPath + 'account/update/step3'); 
       }, 
       function (failureResult) { 
        $scope.accountModelStep2.errors = failureResult.data; 
        viewModelHelper.modelErrors = $scope.accountModelStep2.errors; 
        viewModelHelper.modelIsValid = false; 
       } 
       ); 
     } 
     else 
      viewModelHelper.modelErrors = $scope.accountModelStep2.errors; 
    } 

    $scope.backToStep1 = function() { 
     $location.path(Avts.rootPath + 'account/update/step1'); 
    } 

    setupRules(); 
}); 

accountUpdateModule.controller("AccountUpdateStep3ViewModel", function ($scope, $http, $location, viewModelHelper, validator) { 

    if (!$scope.accountModelStep2.Initialized) { 
     // got to this controller before going through step 2 
     $location.path(Avts.rootPath + 'account/update/step2'); 
    } 

    var accountModelStep3Rules = []; 

    var setupRules = function() { 

     accountModelStep3Rules.push(new validator.PropertyRule("Address", { 
      required: { message: "Address is required" } 
     })); 
     accountModelStep3Rules.push(new validator.PropertyRule("City", { 
      required: { message: "City is required" } 
     })); 
     accountModelStep3Rules.push(new validator.PropertyRule("State", { 
      required: { message: "State is required" } 
     })); 
     accountModelStep3Rules.push(new validator.PropertyRule("PostalCode", { 
      required: { message: "Postal code is required" }, 
      pattern: { message: "Postal code is in invalid format", params: /^[1-9][0-9]{5}$/ } 
     })); 

     //accountModelStep3Rules.push(new validator.PropertyRule("CreditCard", { 
     // required: { message: "Credit Card # is required" }, 
     // pattern: { message: "Credit card is in invalid format (16 digits)", params: /^\d{16}$/ } 
     //})); 
     //accountModelStep3Rules.push(new validator.PropertyRule("ExpiryDate", { 
     // required: { message: "Expiration Date is required" }, 
     // pattern: { message: "Expiration Date is in invalid format (MM/YY)", params: /^(0[1-9]|1[0-2])\/[0-9]{2}$/ } 
     //})); 
    } 


    $scope.confirm = function() { 
     validator.ValidateModel($scope.accountModelStep3, accountModelStep3Rules); 
     viewModelHelper.modelIsValid = $scope.accountModelStep3.isValid; 
     viewModelHelper.modelErrors = $scope.accountModelStep3.errors; 
     if (viewModelHelper.modelIsValid) { 
      viewModelHelper.apiPost('api/account/update/validate3', $scope.accountModelStep3, 
       function (result) { 
        $scope.accountModelStep3.Initialized = true; 
        $location.path(Avts.rootPath + 'account/update/confirm'); 
       }, 
       function (failureResult) { 
        $scope.accountModelStep3.errors = failureResult.data; 
        viewModelHelper.modelErrors = $scope.accountModelStep3.errors; 
        viewModelHelper.modelIsValid = false; 
       } 
       ); 
     } 
     else 
      viewModelHelper.modelErrors = $scope.accountModelStep3.errors; 
    } 

    $scope.backToStep2 = function() { 
     $location.path(Avts.rootPath + 'account/update/step2'); 
    } 

    setupRules(); 
}); 

accountUpdateModule.controller("AccountUpdateConfirmViewModel", function ($scope, $http, $location, $window, viewModelHelper) { 

    if (!$scope.accountModelStep3.Initialized) { 
     // got to this controller before going through step 3 
     $location.path(Avts.rootPath + 'account/update/step3'); 
    } 

    $scope.updateAccount = function() { 

     // Video 147 2:00 Sec 
     var accountModel; 

     accountModel = $.extend(accountModel, $scope.accountModelStep1); 
     accountModel = $.extend(accountModel, $scope.accountModelStep2); 
     accountModel = $.extend(accountModel, $scope.accountModelStep3); 

     viewModelHelper.apiPost('api/account/update', accountModel, 
      function (result) { 
       //$location.path(Avts.rootPath); 
       $location.path(Avts.rootPath + 'account/update/successfullyupdated'); 
       //account/update/successfullyupdateded 
       //account/update/successfullyupdated 
       //$window.location.href = Avts.rootPath; 
      }, 
      function (failureResult) { 
       $scope.accountModelStep1.errors = failureResult.data; 
       viewModelHelper.modelErrors = $scope.accountModelStep1.errors; 
       viewModelHelper.modelIsValid = false; 
      } 
      ); 
    } 

    $scope.backToStep3 = function() { 
     $location.path(Avts.rootPath + 'account/update/step3'); 
    } 
}); 

//AccountUpdateSuccessfullyUpdatedViewModel 

accountUpdateModule.controller("AccountUpdateSuccessfullyUpdatedViewModel", function ($scope, $http, $location, $window, viewModelHelper) { 

}); 

答えて

2

です。あなたはあなたのroute.configにそれを登録していません。設定しなかった場合、どこにも使用しないことを意味します。

望ましくないモデルを削除してください。 rout configセクションに登録してください。

1

私はindex.htmlで、ファイルをインポートし、私の問題は、

<script src=".../AccountUpdateStep1ViewModel.js"></script> 
を解決
関連する問題