I have the following code in my template:
<li class="row timeline-item" data-ng-repeat="item in data | filter:workoutFilter" data-ng-include="getTemplateUrl(item)"></li>
And this is what I have in my controller:
$scope.workoutFilter = null;
$rootScope.$on('workout', function(e, data) {
$scope.workoutFilter = "{Type: 'workout'}";
});
Whenever I click the workouts button, all the items seem to disappear even though there are items that match the filter. The getTemplateUrl function successfully identifies the workout type and returns the correct template.
Why is this happening? Is there a different method I can use to filter items with the property Type set to "workout"?
UPDATE
Here is what unfolds when I click the button:
In another controller:
$scope.onWorkoutsClick = function () {
feedService.setWorkoutFilter();
};
In the service:
setWorkoutFilter : function() {
$rootScope.$broadcast('workout');
}
And in my primary controller:
$rootScope.$on('workout', function(e, data) {
$scope.workoutFilter = "{Type: 'workout'}";
});