Sharing Top Content from the Angular-sphere.

AngularJS — placeholder for empty result from filter

  • ProblemI want to have a place holder, e.g. No result when filter result returns empty.
  • I don’t even know where to start…HTML:div ng-controller=”Ctrl”h1My Foo/h1ul li ng-repeat=”foo in foos” a href=”#” /li/ulbr /h1My Bar/h1ul li ng-repeat=”bar in bars | Ctrl($scope) { $scope.foos = [{ name: ‘Foo 1’ },{ name: ‘Foo 2’ },{ name: ‘Foo 3’ }]; $scope.bars = [{ name: ‘Bar 1’, foo: ‘Foo 1’ },{ name: ‘Bar 2’, foo: ‘Foo 2’ }]; $scope.setBarFilter = function(foo_name) { $scope.barFilter = {}; $scope.barFilter.foo = foo_name; }}jsFiddle: courtesy of: Adrian GunawanSolutionA tweak on the approach that only requires you to specify the filter once:li ng-repeat=”bar in filteredBars = (bars | here!
  • /pFiddleSolution courtesy of: Mark RajcokView additional discussion.

“AngularJS — placeholder for empty result from filter” is published by Angular.js Recipes

@_adeeb: AngularJS — placeholder for empty result from filter #angularjs #javascript #angular

when filter result returns empty. Could anyone please help? I don’t even know where to start…

name: ‘Foo 1’

name: ‘Foo 2’

name: ‘Foo 3’

name: ‘Bar 1’,

foo: ‘Foo 1’

name: ‘Bar 2’,

foo: ‘Foo 2’

Thanks!

Problem courtesy of: Adrian Gunawan

A tweak on the approach that only requires you to specify the filter once:

Solution courtesy of: Mark Rajcok

AngularJS — placeholder for empty result from filter

Comments are closed, but trackbacks and pingbacks are open.