2017-08-03 13 views
2

私は自分のプロジェクトに角度経路を使用しています。私のプロジェクト構造は以下の通りです。添付されたコントローラの角度経路の問題

index page

<body ng-app="myApp"> 
    <div ng-view></div> 


    <script src="resources/js/angular.js" type="text/javascript"></script> 
    <script src="resources/angular/angular-route.js" type="text/javascript"></script> 
    <script src="resources/js/route.js" type="text/javascript"></script> 
    <script src="resources/js/quotation.js" type="text/javascript"></script> 
    <script src="resources/js/container_details.js" type="text/javascript"></script> 
    <script src="resources/angular/angular-modal-service.js" type="text/javascript"></script> 
    <script src="/containers/resources/js/user-registration.js" type="text/javascript"></script> 
</body> 

私route.jsは、私は以下のようにすべてのモジュールを定義し

var app = angular.module('myApp',['ngTable','jcs-autoValidate','ngRoute']); 

    // configure our routes 
    app.config(function($routeProvider,$locationProvider) { 

     $routeProvider 
     .when('/containers', { 
      templateUrl : 'template.jsp' 


     }) 
      .when('/container-details', { 
       templateUrl : 'container-details.jsp', 
       controller : 'myCtrl' 

      }) 
      .when('/quotation-approve', { 
       templateUrl : 'quotation_approve.jsp', 
       controller : 'ourCtrl' 

      }) 
       .when('/user-registration', { 
       templateUrl : 'user-registration.jsp', 
       controller : 'userCtrl' 

      }) 


     $locationProvider.html5Mode(true); 
    }); 

/* app.config(["$routeProvider", "$locationProvider", function ($routeProvider, $locationProvider) { 
     $locationProvider.html5Mode(true);*/ 

ファイル:私は、ページエラーが発生したときにロード

var app = angular.module("myApp"); 

。エラーは、この上記のコードはmyAppそれだけで既存のモジュールを参照すると呼ばれるモジュールを作成しません enter image description here

user registration.js

var app = angular.module("myApp"); 
 

 
app.run(function(defaultErrorMessageResolver, validator) { 
 
    validator.setValidElementStyling(false); 
 
    defaultErrorMessageResolver.getErrorMessages().then(function(errorMessages) { 
 
    errorMessages['min-length'] = 'Username must be at least {0} letters'; 
 
    errorMessages['max-length'] = 'Username must be {0} letters Only'; 
 
    errorMessages['pwError'] = "Password should be atleast 8 characters long and should contain one number,one character and one special character"; 
 
    errorMessages['passwordVerify'] = "password not matched"; 
 
    errorMessages['validEmail'] = "Please enter a valid email address"; 
 
    }); 
 

 
}); 
 

 

 
app.controller('userCtrl', function($scope, $http, NgTableParams, $timeout, $filter) { 
 

 
    $scope.getAllUserDetails = function() { 
 
    $http({ 
 
     method: "GET", 
 
     url: "/containers/getUserRolle" 
 
    }).then(function mySucces(response) { 
 
     $scope.getAllRolesDetails(); 
 
     $scope.userRolless = response.data.userRolles; 
 
     //  console.log($scope.userRolless); 
 
     $scope.getDatas(); 
 
    }, function myError(response) { 
 
     $scope.userRolless = response.data.userRolles; 
 
    }); 
 
    } 
 

 

 
    $scope.getAllTableData = function() { 
 
    // $scope.edituserdetails={}; 
 
    //$scope.edituserdetails.activeuser=true; 
 
    $http({ 
 
     method: "GET", 
 
     url: "/containers/getUserRolle" 
 
    }).then(function mySucces(response) { 
 
     // \t \t  \t $scope.getAllRolesDetails(); 
 
     $scope.userRolless = response.data.userRolles; 
 
     // \t \t   console.log($scope.userRolless); 
 
     $scope.getDatas(); 
 
    }, function myError(response) { 
 
     $scope.userRolless = response.data.userRolles; 
 
    }); 
 
    } 
 

 
    $scope.getDatas = function() { 
 
    console.log("tesssst" + $scope.userRolless); 
 
    //console.log("tesssst"+$scope.userRolless.object.name); 
 
    $scope.tableParams = new NgTableParams({ 
 
     page: 1, // show first page 
 
     count: 5, 
 
     // count per page 
 
     // filter: {name: '' }, 
 
     // sorting: { username: "asc" }, 
 

 
    }, { 
 
     dataset: $scope.userRolless 
 
    }); 
 

 
    } 
 

 

 

 

 

 

 
    $scope.getAllRolesDetailsById = function(roleId) { 
 

 
    $http({ 
 
     method: "GET", 
 
     url: "/containers/getUserRoleById", 
 
     params: { 
 
     roleId: roleId 
 
     } 
 
    }).then(function mySucces(response) { 
 
     console.log(response.data.userAllRollesById); 
 
     $scope.userAllRolles = response.data.userAllRollesById; 
 
     $scope.edituserdetails.role = $scope.userAllRolles[0]; 
 

 
     // console.log("user Active status"+ $scope.edituserdetails.activeuser); 
 
    }, function myError(response) { 
 
     console.log(response.data.userAllRolles); 
 
     $scope.userAllRolles = response.data.userAllRollesById; 
 
    }); 
 

 
    } 
 

 
    $scope.editUserFunction = function(usersid) { 
 

 
    $http({ 
 
     method: "GET", 
 
     url: "/containers/getUserDetails", 
 
     params: { 
 
     userId: usersid 
 
     } 
 
    }).then(function mySucces(response) { 
 
     $scope.edituserdetails = response.data.userDetails; 
 
     $scope.username = response.data.userDetails.username; 
 
     $scope.getAllRolesDetailsById($scope.edituserdetails.roleId); 
 
     console.log(response.data.userDetails); 
 

 
     console.log("user Active status" + response.data.userDetails.userstatus); 
 
     if (response.data.userDetails.userstatus === 'Y') { 
 
     $scope.edituserdetails.activeuser = true; 
 
     } else { 
 
     $scope.edituserdetails.activeuser = false; 
 
     } 
 
     $scope.edituserdetails.password = ""; 
 
     $scope.edituserdetails.confirmpassword = ""; 
 
    }, function myError(response) { 
 
     $scope.edituserdetails = response.data.userRolles; 
 
    }); 
 

 
    //  \t console.log(usersid); 
 
    } 
 

 

 
    $scope.getExistingUserValidateFunction = function(userName) { 
 

 
    $http({ 
 
     method: "GET", 
 
     url: "/containers/validateUser", 
 
     params: { 
 
     userName: userName 
 
     } 
 
    }).then(function mySucces(response) { 
 
     var test = response.data.ExistingUserStatus 
 
     console.log("ddddd" + test); 
 
     return test; 
 

 
    }, function myError(response) { 
 
     //  \t return response.data.ExistingUserStatus; 
 
    }); 
 

 
    } 
 

 

 
    $scope.changePassword = function() { 
 
    console.log("ddddd" + $scope.edituserdetails.activeuser); 
 
    if ($scope.edituserdetails.activeuser) { 
 
     activeuserstatus = 'Y'; 
 
    } else { 
 
     activeuserstatus = 'N'; 
 
    } 
 
    console.log("ccccc" + activeuserstatus); 
 
    $http({ 
 
     method: "POST", 
 
     url: "/containers/registrationuser", 
 
     data: { 
 
      "email": $scope.edituserdetails.email, 
 
      "username": $scope.username, 
 
      "password": $scope.edituserdetails.password, 
 
      "id": $scope.edituserdetails.id, 
 
      "role": $scope.edituserdetails.role, 
 
      "userstatus": activeuserstatus 
 

 

 
     } 
 

 
     }) 
 
     .success(function(data) { 
 
     $timeout(function() { 
 
      $scope.msgType = false; 
 
     }, 3000); 
 
     $scope.theform.$setPristine(); 
 
     if (data.errorList.length > 0) { 
 
      $scope.fieldErrorList = data.errorList; 
 
      $scope.msgType = 'Error'; 
 
     } else { 
 
      $scope.msgType = 'Success'; 
 
      $scope.getAllTableData(); 
 
     } 
 

 
     $scope.theform.$setPristine(); 
 
     // \t \t \t \t \t document.body.scrollTop = document.documentElement.scrollTop = 0; 
 

 

 

 
     //    $scope.resetFunction(); 
 

 
     }); 
 

 

 

 
    // Posting data to php file 
 
    } 
 

 
    /* form.$setPristine = function() { 
 
\t  $animate.setClass(element, PRISTINE_CLASS, DIRTY_CLASS + ' ' + SUBMITTED_CLASS); 
 
\t  form.$dirty = false; 
 
\t  form.$pristine = true; 
 
\t  form.$submitted = false; 
 
\t  forEach(controls, function(control) { 
 
\t  control.$setPristine(); 
 
\t  }); 
 
\t };*/ 
 

 
    $scope.saveUserFunction = function() { 
 
    console.log("ddddd" + $scope.edituserdetails.activeuser); 
 
    if ($scope.edituserdetails.activeuser) { 
 
     activeuserstatus = 'Y'; 
 
    } else { 
 
     activeuserstatus = 'N'; 
 
    } 
 
    console.log("ccccc" + activeuserstatus); 
 
    $http({ 
 
     method: "POST", 
 
     url: "/containers/registrationuser", 
 
     data: { 
 
      "email": $scope.edituserdetails.email, 
 
      "username": $scope.username, 
 
      "password": $scope.edituserdetails.password, 
 
      "id": $scope.edituserdetails.id, 
 
      "role": $scope.edituserdetails.role, 
 
      "userstatus": activeuserstatus 
 

 

 
     } 
 

 
     }) 
 
     .success(function(data) { 
 
     console.log($scope.theform); 
 
     if (data.errorList.length > 0) { 
 
      $scope.fieldErrorList = data.errorList; 
 
      $scope.msgType = 'Error'; 
 
      $scope.theform.$setPristine(); 
 
     } else { 
 
      $scope.msgType = 'Success'; 
 
      // $scope.edituserdetails = {}; 
 
      $scope.resetFunction(); 
 
      $scope.getAllTableData(); 
 
      $timeout(function() { 
 
      $scope.msgType = false; 
 
      }, 3000); 
 
      $scope.theform.$setPristine(); 
 
     } 
 

 

 
     // \t \t \t \t \t document.body.scrollTop = document.documentElement.scrollTop = 0; 
 

 

 

 
     $scope.resetFunction(); 
 
     $scope.theform.$setPristine(); 
 
     }); 
 

 

 

 
    // Posting data to php file 
 
    } 
 

 

 
    $scope.resetFunction = function() { 
 
    $scope.edituserdetails = {}; 
 
    $scope.username = ''; 
 
    $scope.edituserdetails.role = $scope.userAllRolles[0]; 
 
    $scope.theform.$setPristine(); 
 
    } 
 

 
    $scope.checkPwd = function() { 
 

 
    var str = document.getElementById('pw').value; 
 
    if (str.length < 6) { 
 
     alert("too_short"); 
 
     return ("too_short"); 
 
    } else if (str.length > 50) { 
 
     alert("too_long"); 
 
     return ("too_long"); 
 
    } else if (str.search(/\d/) == -1) { 
 
     alert("no_num"); 
 
     return ("no_num"); 
 
    } else if (str.search(/[a-zA-Z]/) == -1) { 
 
     alert("no_letter"); 
 
     return ("no_letter"); 
 
    } else if (str.search(/^(?=.*[A-Za-z])(?=.*\d)(?=.*[[email protected]$!%*#?&])[A-Za-z\[email protected]$!%*#?&]{8,}$/) != -1) { 
 
     alert("bad_char"); 
 
     return ("bad_char"); 
 
    } 
 
    alert("oukey!!"); 
 
    return ("ok"); 
 
    } 
 

 

 
    $scope.changePasswordFucntion = function(username) { 
 
    console.log(username); 
 

 
    $http({ 
 
     method: "POST", 
 
     url: "/containers/changePassword", 
 
     data: { 
 
      "password": $scope.edituserdetails.password, 
 
      "username": username, 
 
      "curruntPassword": $scope.edituserdetails.curruntpassword, 
 
      "passwordConfirm": $scope.edituserdetails.confirmpassword 
 

 
     } 
 

 
     }) 
 
     .success(function(data) { 
 
     $timeout(function() { 
 
      $scope.msgType = false; 
 
     }, 3000); 
 
     $scope.theform.$setPristine(); 
 
     if (data.errorList.length > 0) { 
 
      $scope.fieldErrorList = data.errorList; 
 
      $scope.msgType = 'Error'; 
 
     } else { 
 
      $scope.msgType = 'Success'; 
 
      $scope.getAllTableData(); 
 
     } 
 

 
     $scope.theform.$setPristine(); 
 

 

 
     }); 
 
    } 
 

 
    $scope.getAllRolesDetails = function() { 
 

 
    $http({ 
 
     method: "GET", 
 
     url: "/containers/getUserAlRolles" 
 
    }).then(function mySucces(response) { 
 
     // \t console.log(response.data.userAllRolles); 
 
     $scope.userAllRolles = response.data.userAllRolles; 
 
     $scope.edituserdetails = response.data.userAllRolles; 
 
     $scope.edituserdetails.role = response.data.userAllRolles[0]; 
 

 
    }, function myError(response) { 
 
     // \t console.log(response.data.userAllRolles); 
 
     $scope.userAllRolles = response.data.userAllRolles; 
 
    }); 
 

 
    } 
 

 

 

 

 
}) 
 
app.directive("passwordVerify", function() { 
 
    return { 
 
    require: "ngModel", 
 
    scope: { 
 
     passwordVerify: '=' 
 
    }, 
 
    link: function(scope, element, attrs, myCtrl) { 
 
     scope.$watch(function() { 
 
     var combined; 
 

 
     if (scope.passwordVerify || myCtrl.$viewValue) { 
 
      combined = scope.passwordVerify + '_' + myCtrl.$viewValue; 
 
     } 
 
     return combined; 
 
     }, function(value) { 
 
     if (value) { 
 
      myCtrl.$parsers.unshift(function(viewValue) { 
 
      var origin = scope.passwordVerify; 
 
      if (origin !== viewValue) { 
 
       myCtrl.$setValidity("passwordVerify", false); 
 
       return undefined; 
 
      } else { 
 
       myCtrl.$setValidity("passwordVerify", true); 
 
       return viewValue; 
 
      } 
 
      }); 
 
     } 
 
     }); 
 
    } 
 
    }; 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

+0

'ユーザーregistration.js' – Rahul

+0

私が編集のためのコードを表示してください。 plsは親愛なるRahulをチェックします – user1177842

+0

あなたはuser-registration.jsとroute.jsで 'var app = angular.module(" userRegistration ");'のような別のモジュールを使ってみることができます 'var app = angular.module( 'myApp'、[ 'ngTable'、 'jcs-autoValidate'、 'ngRoute'、 'userRegistration']); ' – Rahul

答えて

0

var app = angular.module("myApp");

言いました。まだモジュールを作成していない場合は、あなたが言及したエラーがスローされます。

モジュールを作成するには、これを行います。

angular.module('myApp', []);


詳細に議論以下、これをお読みください:

Meaning of the empty array in angularJS module declaration

+0

親愛なるラメッシュに、私はroute.jsにすべてのものを注入しました。他のjsファイルは以下のように保存されます var app = angular.module( "myApp"); – user1177842

+0

Ramesh、Not Rumesh :)しかし、関連するスクリプトファイルをインデックスページで参照しましたか? –

+0

インデックスファイルに添付されたすべてのjsファイル – user1177842

関連する問題