Hi,

        I am trying to get details of a particular employee from database
but I am getting the error like this

 TypeError: Cannot read property '7698' of undefined
    at l.$scope.setAirport (
http://localhost:8082/RESTJERSYExampleMobile/js/controller/app.js:18:45)
    at ib.functionCall (
https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js:198:303
)
    at Dc.(anonymous function).compile.d.on.f (
https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js:214:485
)
    at l.$get.l.$eval (
https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js:125:305
)
    at l.$get.l.$apply (
https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js:126:6)
    at HTMLAnchorElement.<anonymous> (
https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js:215:36
)
    at HTMLAnchorElement.c (
https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js:32:389)angular.js:11607
(anonymous function)angular.js:8557 $getangular.js:14502
$get.l.$applyangular.js:21440 (anonymous function)angular.js:3014 c


and my* index.html* is

<!DOCTYPE html>
<html ng-app="emp">
<head>
<meta charset="ISO-8859-1">
<title>New Project</title>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js
"></script>
<script type="text/javascript"
src="
https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular-resource.min.js
"></script>
<script type="text/javascript"
src="
https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular-route.min.js
"></script>

<script type="text/javascript" src="js/controller/app.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css"
href="css/bootstrap-theme.min.css">
<link rel="stylesheet" type="text/css"
href="css/bootstrap-responsive.min.css">

</head>
<body>
<div class="container" ng-controller="MainCtrl">

<h1>Employee Details</h1>


<div ng-view></div>

</div>

</body>
</html>

*js/controller/app.js* is

var myapp=new angular.module('myapp',['ngResource']);
myapp.controller("MainCtrl",["$scope","$resource",function($scope,$resource){
var user=$resource("
http://192.168.100.177:8082/RESTJerseyExample/rest/restfultest/GetCarValues
");
$scope.list=function(){
user.query(function(data){
$scope.users=data;
},function(error){
alert(error.data);
});
 };
$scope.sidebarURL = 'partials/airport.html';
  $scope.currentAirport = null;

  $scope.setAirport = function (Empno) {
  alert(Empno);

    $scope.currentAirport = $scope.airports[Empno];

  };
$scope.list();
$scope.sortfield='Empno';
$scope.reverse=true;

}]);


*js/app.js*

angular.module('emp',['ngRoute','myapp']).config(airlineRouter);
function airlineRouter($routeProvider){
$routeProvider.when('/',{templateUrl: 'partials/destinations.html'});
}

partials/destinations.html


<div>
<h3>All Employee Numbers</h3>
<ul>
<li ng-repeat="u in users">
<a href="" ng-click="setAirport(u.Empno)">{{u.Empno}}</a>
</li>
</ul>

</div>
<div ng-include src="sidebarURL"></div>

*partials/airport.html*

<div ng-show="currentAirport">
<h3>Employee</h3>
<ul>
<li>
{{currentAirport.Empno}}
{{currentAirport.EmpName}}
{{currentAirport.Job}}
{{currentAirport.Mgr}}
{{currentAirport.HireDate}}
{{currentAirport.Sal}}
{{currentAirport.Comm}}
{{currentAirport.DeptNo}}
</li>
</ul>


</div>


If you have any idea please share answer

Thanks&Regards,
Bhagyasri.T

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to