角度页面错误

时间:2015-06-30 15:08:22

标签: javascript php angularjs

我收到了错误

SCRIPT5009: 'selectedCircuit' is undefined 
angular.min.js?1435676209, line 24 character 479
Error: Could not complete the operation due to error 80020101.<div class="ng-scope" ng-view=""> 
for the following code, where it is being called by another page that already has angular loaded in

(如果需要,我可以发布其他页面)

 <div role="toolbar">
    <div class="btn-group">
    <button type="button" class="btn btn-default" ng-click="projectFilter = ''">          <strong>All Projects</strong></button>
    <button type="button" class="btn btn-default" ng-repeat="project in projects" ng-click="setFilter(project.PROJECT)"><strong>{{project.PROJECT}}</strong></button>
  </div>
</div>
<hr>
<h3><strong>{{projectFilter}}</strong></h3>
<h3 ng-show="projectFilter == ''"><strong>All Projects</strong></h3>
<div class="row">
    <div class="col-md-4">
        <analysis-list></analysis-list>
    </div>
     <div class="col-md-4">
        <dew-list></dew-list>
     </div>
    <div class="col-md-4">
        <js-list></js-list>
    </div>
   </div>
   <hr>

   <!--modal-->
    <script type="text/ng-template" id="donecircuitviewmodal.html"></script>
        <div class="modal-header">
            <h1><script>{{selectedCircuit.CIRCUIT}}</script></h1>
        </div>
        <div class="modal-body">

        <h2><span class="glyphicon glyphicon-user"></span> Preparers </h2>
            <div class="row">
                <div class="col-md-4">Analysis by<br><script>{{selectedCircuit.ANALYSIS_PREPARER}}</script></div>
                <div class="col-md-4">Circuit Prep by<br><script>{{selectedCircuit.DEW_PREPARER}}</script></div>
                <div class="col-md-4">Jumper Study by<br><script>{{selectedCircuit.JUMPERSTUDY_PREPARER}}</script></div>
            </div>
        <hr>

        <h2><span class="glyphicon glyphicon-comment"></span> Discussion </h2>

        <div class="panel panel-default widget">
            <div class="panel-heading">
                <span class="label label-info">
                    <script>{{circuitComments.length}}</script>
                </span>
            </div>
            <div class="panel-body">
                <ul class="list-group">
                    <li class="list-group-item" ng-repeat="comment in circuitComments">
                        <div class="row">
                            <div class="col-xs-2 col-md-2">
                                <img ng-src="{{comment.IMGURL}}" class="img-circle img-thumbnail" alt=""></div>
                            <div class="col-xs-10 col-md-10">
                                <div>
                                    <div class="mic-info">
                                        By: <a><script>{{comment.EMPLOYEE_ID}}</script></a> on <script>{{comment.COMM_DATE}}</script>
                                    </div>
                                </div>
                                <div class="comment-text" style="margin-bottom: 5px">
                                    <script>{{comment.COMM}}</script>
                                </div>
                                <div class="action">
                                    <button type="button" class="btn btn-danger btn-xs" title="Delete" ng-if="comment.EMPLOYEE_ID == viewer.name" ng-click="deleteComment(comment.COMM_ID)">
                                        <span class="glyphicon glyphicon-trash"></span>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>

                <div class="row" style="margin-bottom: 8px">
                    <script>{{newComm}}</script>
                    <div class="col-md-10">
                        <textarea class="form-control" ng-model="selectedCircuit.COMM"></textarea>
                    </div>
                    <div class="col-md-2">
                    <button class="btn btn-default" ng-click="submitComment()" ng-disabled="selectedCircuit.COMM.length == 0">Submit</button>
                    </div>
                </div>

                <button class="btn btn-primary btn-sm btn-block" ng-click="reloadComments()"><span class="glyphicon glyphicon-refresh"></span> Refresh</button>
            </div><!--panelbody-->
        </div>

        </div>
        <div class="modal-footer">
            <button class="btn btn-primary" ng-click="ok()">OK</button>
            <button class="btn btn-warning" ng-click="cancel()">Cancel</button>
        </div>

控制器

    var studentApp = angular.module('studentApp', ['ngRoute', 'ui.bootstrap', 'ngGrid', 'ngIdle']);

// configure our routes
studentApp.config(function($routeProvider) {
    $routeProvider
        // route for the home page
        .when('/', {
            templateUrl : 'pages/home/mycircuits.html',
            controller  : 'myCircuits'
        })

    .when('/allcircuits', {
      templateUrl :'pages/home/allcircuits.html',
      controller : 'allCircuits'
    })
    .when('/export', {
        templateUrl : 'pages/admin/export.html',
        controller : 'ExportController'
    })
    .when('/swi', {
      templateUrl :'pages/home/swi.html',
      controller: 'swiController'
    })

    .when('/metrics', {
      templateUrl:'pages/admin/newmetrics.html',
      controller:'MetricsController'
    })

    .when('/postefcircuits', {
      templateUrl : 'pages/home/postefcircuitlist.html',
      controller : 'PostEfCircuitController'
    })
});

//Controller=================================================================================================
studentApp.controller('myCircuits', function($scope, $idle, $keepalive, $modal, $log, $http) {
  $idle.watch();
  $scope.projects = [];
  $scope.projectFilter = '';

  //get list of projects
  $http.post('src/php/studentEngine.php?method=selectUniqueProjects')
    .success(function(data){
      $scope.projects = data;
    });

  $scope.setFilter = function(projectName){
    if (projectName == 'Not Labeled') $scope.projectFilter = '';
    else $scope.projectFilter = projectName;
  }
  function closeModals() {
    if ($scope.warning) {
      $scope.warning.close();
      $scope.warning = null;
    }

    if ($scope.timedout) {
      $scope.timedout.close();
      $scope.timedout = null;
    }
  }

  //has to do with timeout auto log off crap
  $scope.$on('$idleStart', function() {
    closeModals();

    $scope.warning = $modal.open({
      templateUrl: 'warning-dialog.html',
      windowClass: 'modal-danger'
    });
  });

  $scope.$on('$idleEnd', function() {
    closeModals();
  });

  $scope.$on('$idleTimeout', function() {
    closeModals();
    $scope.timedout = $modal.open({
      templateUrl: 'timedout-dialog.html',
      windowClass: 'modal-danger',
      controller: TimeoutModalController,
      size: 'md',
      resolve: {
        item: function(){
          return "";
        }
      }
    });
  });

  $scope.doneCircuitView = function(circuit) {

    var modalInstance = $modal.open({
      templateUrl: 'donecircuitviewmodal.html',
      controller: CircuitViewModal,
      size: 'md',
      resolve: {
        items: function() {
          return circuit;
        }
      }
    });

    modalInstance.result.then(function(selectedCircuit){

    }, function(){
      //log
    });
  };
})
.config(function($idleProvider, $keepaliveProvider){
    $idleProvider.idleDuration(80000);
    $idleProvider.warningDuration(5);
    $keepaliveProvider.interval(10);
})
.directive('analysisList', function(){
  return {
    restrict: 'E',
    templateUrl: 'templates/student/analysis-list.html?' + Math.floor((Math.random() * 100) + 1),
    controller: function($scope, $modal, $log, $http, $cacheFactory) {
      var $httpDefaultCache = $cacheFactory.get('$http');
      $httpDefaultCache.removeAll();

      $scope.analysisINCOMPLETE = [];
      $scope.analysisCOMPLETE = [];
      $scope.availableAnalysis = [];
      $scope.errors = [];

      //get student completed, incompleted
      $http.post('src/php/studentEngine.php?method=getStudentCircuits', {'TYPE':'ANALYSIS'})
        .success(function(data){
          if(data.INCOMPLETE) $scope.analysisINCOMPLETE = data.INCOMPLETE;
          if(data.COMPLETE) $scope.analysisCOMPLETE = data.COMPLETE;
        });

      $scope.addAnalysis = function () {
        var modalInstance = $modal.open({
            templateUrl: 'addanalysiscircuitmodel.html',
            controller: StudentAddCircuitModel,
            size: 'md',
            resolve: {
              data: function () {
                var data = {type:'ANALYSIS', project: $scope.projectFilter};
                return data;
              }
            }
          });

        modalInstance.result.then(function (selectedItem) {
         angular.forEach(selectedItem, function(value, key){
          value.ANALYSIS_ASSIGN_DATE = Date();
          $scope.analysisINCOMPLETE.push(value);
         });
        }, function () {

        });
      };

      $scope.completeAnalysis = function(circuit) {
        $http.post('src/php/studentEngine.php?method=completeCircuit', {'CIRCUIT': circuit.CIRCUIT, 'TYPE':'ANALYSIS', 'PROJECT': circuit.PROJECT})
          .success(function(data){
              if (data == 1) {
                circuit.ANALYSIS_COMP_DATE = Date();
                $scope.analysisINCOMPLETE.splice($scope.analysisINCOMPLETE.indexOf(circuit), 1);
                $scope.analysisCOMPLETE.push(circuit);
              } else $scope.erorrs = data;
          });
      };

      $scope.removeAnalysis = function(circuit) {
        $http.post('src/php/studentEngine.php?method=removeCircuit', {'CIRCUIT':circuit.CIRCUIT, 'TYPE':'ANALYSIS', 'PROJECT':circuit.PROJECT})
          .success(function(data){
            if (data == 1) {
                $scope.analysisINCOMPLETE.splice($scope.analysisINCOMPLETE.indexOf(circuit), 1);
            } else $scope.errors = data;
          });
      };


    },
    controllerAs: 'AnalysisCtrl'
  }
})
.directive('dewList', function(){
  return {
    restrict: 'E',
    templateUrl: 'templates/student/dew-list.html?' + Math.floor((Math.random() * 100) + 1),
    controller: function($scope, $modal, $log, $http) {
      $scope.dewINCOMPLETE = [];
      $scope.dewCOMPLETE = [];
      $scope.availableDEW = [];
      $scope.errors = [];

      $http.post('src/php/studentEngine.php?method=getStudentCircuits', {'TYPE':'DEW'})
        .success(function(data){
          if(data.INCOMPLETE) $scope.dewINCOMPLETE = data.INCOMPLETE;
          if(data.COMPLETE)  $scope.dewCOMPLETE = data.COMPLETE
        });

        $scope.addDEW = function () {
            var modalInstance = $modal.open({
                    templateUrl: 'addcircuitmodel.html',
                    controller: StudentAddCircuitModel,
                    size: 'md',
                    resolve: {
                        data: function () {
              var data = {type:'DEW', project: $scope.projectFilter};
                        return data;
                    }
                }
            });

            modalInstance.result.then(function (selectedItem) {
                    angular.forEach(selectedItem, function(value, key){
                    value.DEW_ASSIGN_DATE = Date();
                    $scope.dewINCOMPLETE.push(value);
                });
                }, function () {
            });
        };

      $scope.completeDEW = function(circuit) {

        $http.post('src/php/studentEngine.php?method=completeCircuit', {'CIRCUIT': circuit.CIRCUIT, 'TYPE':'DEW', 'PROJECT': circuit.PROJECT})
          .success(function(data){
              if (data == 1) {
                circuit.DEW_COMP_DATE = Date();
                $scope.dewINCOMPLETE.splice($scope.dewINCOMPLETE.indexOf(circuit), 1);
                $scope.dewCOMPLETE.push(circuit);
              } else $scope.errors = data;
          });
      };

      $scope.removeDEW = function(circuit) {
        $http.post('src/php/studentEngine.php?method=removeCircuit', {'CIRCUIT':circuit.CIRCUIT, 'TYPE':'DEW', 'PROJECT': circuit.PROJECT})
          .success(function(data){
            if (data == 1) {
                $scope.dewINCOMPLETE.splice($scope.dewINCOMPLETE.indexOf(circuit), 1);
            } else $scope.errors = data;
          });
      };
    },
    controllerAs: 'dewPanel'
  }
})
.directive('jsList', function(){
  return {
    restrict: 'E',
    templateUrl: 'templates/student/js-list.html?' + Math.floor((Math.random() * 100) + 1),
    controller: function ($scope, $modal, $log, $http) {
      $scope.jsINCOMPLETE = [];
      $scope.jsCOMPLETE = [];
      $scope.availableJS = [];
      $scope.errors = [];

      //get student completed, incompleted
       $http.post('src/php/studentEngine.php?method=getStudentCircuits', {'TYPE':'JUMPERSTUDY'})
          .success(function(data){
              if(data.INCOMPLETE) $scope.jsINCOMPLETE = data.INCOMPLETE;
              if(data.COMPLETE) $scope.jsCOMPLETE = data.COMPLETE;
          });

      $scope.addJS = function () {
        var modalInstance = $modal.open({
            templateUrl: 'addcircuitmodel.html',
            controller: StudentAddCircuitModel,
            size: 'md',
            resolve: {
              data: function () {
                var data = {type:'JUMPERSTUDY', project: $scope.projectFilter};
                return data;
              }
            }
          });

        modalInstance.result.then(function (selectedItem) {
          angular.forEach(selectedItem, function(value, key){
          value.JUMPERSTUDY_ASSIGN_DATE = Date();
            $scope.jsINCOMPLETE.push(value);
          });
        }, function () {

        });
      };

      $scope.completeJS = function(circuit) {
        $http.post('src/php/studentEngine.php?method=completeCircuit', {'CIRCUIT': circuit.CIRCUIT, 'TYPE':'JUMPERSTUDY', 'PROJECT': circuit.PROJECT})
          .success(function(data){
              if (data == 1) {
                circuit.JUMPERSTUDY_COMP_DATE = Date();
                $scope.jsINCOMPLETE.splice($scope.jsINCOMPLETE.indexOf(circuit), 1);
                $scope.jsCOMPLETE.push(circuit);
              } else $scope.errors = data;
          });
      };

      $scope.uploadJS = function(circuit){
        $http.post('src/php/studentEngine.php?method=uploadJS', {'CIRCUIT': circuit.CIRCUIT, 'PROJECT': circuit.PROJECT})
          .success(function(data){
            if (data == 1) circuit.UPLOADED = 1;
          })
      }

      $scope.removeJS = function(circuit) {
        $http.post('src/php/studentEngine.php?method=removeCircuit', {'CIRCUIT':circuit.CIRCUIT, 'TYPE':'JUMPERSTUDY', 'PROJECT':circuit.PROJECT})
          .success(function(data){
            if (data == 1) {
                $scope.jsINCOMPLETE.splice($scope.jsINCOMPLETE.indexOf(circuit), 1);
            } else $scope.erorrs = data;
          });
      };

    },
    controllerAs: 'jsListPanel'
  }
});


}

0 个答案:

没有答案