TypeError: Cannot read property 'index' of undefined
var crud = angular.module('Crud', ['ngRoute']);
crud.config(['$routeProvider', function($routeProvider){
$routeProvider.when('/edit/:index', {
templateUrl: 'js/views/edit.html',
controller: 'EditCtrl'
}).when('/',{
templateUrl: 'js/views/list.html'
})
}]);
crud.controller('EditCtrl',['$scope', function(scope,$routeParams){
scope.name = scope.names[$routeParams.index];
}]);
Why am i getting index undefined. My url seems to be fine, http://localhost:63342/Angular-CRUD/#/edit/2 It seems that id is passing correctly from view, but why am i getting index undefined in my controller.
indexthat'sundefined, it's the object from which you're trying to accessindexthat isundefined, which would be$routeParams(from the expression$routeParams.index).