I have an array of objects. Each object has multiple properties such as 'activityType'. I'm trying to assign that object to $scope.selectedActivity based on the $scope.activityType value that is already assigned. I've tried to use $filter but I'm not sure how to code the expression properly.
This is my code:
$scope.selectedActivity = $filter('filter')($scope.activityTypes, $scope.activityTypes.activityType == $scope.activityType);
Try this. Give an object for comparision and set to strict (true). Read $filter for more informations.
$scope.selectedActivity = $filter ('filter')($scope.activityTypes, { 'activityType': $scope.activityType }, true);
Okay, asked my question to quickly.
This is how I did it
$scope.selectedActivity = $filter('filter')($scope.activityTypes, { activityType: $scope.activityType} );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.