I'm relatively new to Angular and have run into a problem that I can not figure out what I am doing wrong.
Things work up until I get to the edit record screen. From the listing page(this works), controller1 lists out all data. You can click edit on an item to edit. This loads controller2. From there I am not able to access that element in the array. I can see the whole array however.
I am running my data off of a service as well. The app uses ui-routing so $routeParams
have been changed to $stateParams
.
The code: Service to return data. This part works fine and returns like it should.
.service('attendeeService', function (sfDataProvider) {
var $attendeeDetailList = [];
var $strValue = 'test string';
$attendeeDetailList = sfDataProvider.getAttendeeList();
return {
getAttendees:function () {
return $attendeeDetailList;
},
getString:function () {
return $strValue;
},
addAttendee:function (attendeeName) {
},
deleteAttendee:function (id) {
}
};
Controller1 Lists Array in view. Works fine
.controller( 'AttendeeCtrl', function AttendeeCtrl( $scope, titleService, attendeeService ) {
titleService.setTitle( 'Attendee Badges' );
$scope.strValue = attendeeService.getString();
$scope.attendeeDetailList = attendeeService.getAttendees();
})
Controller2 - I can get the strValue to carry over but cannot access the object fullListAttendees in array to edit item.
.controller( 'AttendeeEditCtrl', function ( $scope, $stateParams, titleService, attendeeService ) {
var $attendeePerson = [];
$scope.fullListAttendees = attendeeService.getAttendees();
$scope.attendeePerson = $scope.fullListAttendees[$stateParams.id];
$scope.strValue = attendeeService.getString();
});
Any thoughts or ideas would be greatly appreciated. I don't know if it matters but this was started from the ng-boilerplate for angular.
Thanks for all help