There seems to be an issue with my ng-repeat on a directive where I'm passing in 3 pieces of information. The directive includes a button that is supposed to pass that information on to another view using params like this:
ui-sref='profiles.show({userId:profile._id, index:index, list:list})
Oddly enough, all the buttons for the cards (which are essentially the directives) work properly, except for the one at index 0. For some reason, the button at index 0 fails to trigger a ui-sref
or a $state.go
. I even tried setting it up with an ng-click and encountered a strange outcome where the console log successfully displayed the correct data, but the $state.go
with the params did not execute.
$state.go('profiles.show', {userId: profile._id, index: index, list: list})
In an attempt to troubleshoot, I noticed that removing the index and the list from the params allowed the ui-sref or $state.go to work for the first element again. However, this caused issues in the subsequent view as it lacked the necessary information.
Here is the state config for profiles.show
.state('profiles.show', {url: '/{userId}', params: { index: null, list: null }, templateUrl:'/views/profiles/show/show.html', controller: 'ProfilesShowController'})
Below is the ng-repeat (written in Jade):
.text-capitalize(al-card, ng-repeat='profile in profiles | filter:searchBar track by $index', profile='profile', index='$index', list='profiles')
Here is the button with the ng-click
event
button.btn.btn-default(ng-click='goToProfile(profile, index, list)') Learn More
And here is the $scope function defined:
$scope.goToProfile = function(profile, index, list) {
console.log(profile);
console.log(index);
console.log(list);
$state.go('profiles.show', {userId: profile._id, index: index, list: list});
};
Any assistance with this dilemma would be greatly appreciated.