-1

This is my url - charts/53d25d91959679701e362f25 and when I add ?widget=true to that link charts/53d25d91959679701e362f25?widget=true I have to hide two particular divs in charts/53d25d91959679701e362f25 page.

I've tried - ng-if="location.path()" but is not working for ?widget=true

Zigma
  • 529
  • 6
  • 37
user3876350
  • 27
  • 1
  • 7

1 Answers1

0

You cannot use $location service in ng-if directive

User $location to set some scope and tie ng-if to that scope variable.

if(angular.isDefined($location.search().widget)) {
     $scope.isHidden = true;
} 
else {
     $scope.isHidden = false;
}

ng-if="isHidden"
msapkal
  • 8,268
  • 2
  • 31
  • 48
  • hi i've tried but it hides that div in all pages (not only in ?widget=true) page – user3876350 Aug 05 '14 at 10:20
  • All the pages? Do you use ngRoute? You can use a controller per page. – msapkal Aug 05 '14 at 10:29
  • OK. A workaround would be try using different scope for each page like isHiddenPage1, isHiddenPage2 etc. – msapkal Aug 05 '14 at 10:41
  • Actually the div is in include file (default.html), i need to hide main menu bar for that page. so there is no seperate controller/scope for that file.. let met try – user3876350 Aug 05 '14 at 10:59