I am using the following code in codepen and facing this issue, for conctact i am getting the following error
Why is it giving error for contact and not for name?
How can i solve this ?
angular.js:13550 ReferenceError: contact is not defined
at new <anonymous> (pen.js:8)
at Object.invoke (angular.js:4665)
at R.instance (angular.js:10115)
at n (angular.js:9033)
at g (angular.js:8397)
at g (angular.js:8400)
at angular.js:8277
at angular.js:1751
at n.$eval (angular.js:17229)
at n.$apply (angular.js:17329)
Here is js file
var app = angular.module("crud", []);
app.controller("ctrl", ['$scope', function($scope) {
$scope.data = [3, 4, 5, 34, 34];
debugger;
$scope.name = name;
$scope.contact = contact;
$scope.obj = {
name: $scope.name,
contact: $scope.contact
};
console.log($scope.obj);
}]);
Here is the HTML file that i am using.
<body ng-app="crud">
<div ng-controller="ctrl">
<div>
<table>
<tr ng-repeat="x in data track by $index">
<td>{{x}}</td>
<td>{{$index}}</td>
</tr>
</table>
</div>
</div>
</body>
PLEASE answer these questions
- Why is it failing at contact and not at name ?
- Contact is number data, what should i give the default value to it ?
$scope.contact?