ngplayground
ngplayground

Reputation: 21627

AngularJS ng-if for $rootScope

In an Angularjs Project I'm trying to get an <a/> to pnly show if $scope.page == 'app'

in my controller $rootScope.page = 'app' and so is $scope.page = 'app' but when I use the following in my DOM it doesn't show when I'm on that page.

<a ng-if="page == 'app'">Show Me</a>

Upvotes: 8

Views: 9326

Answers (2)

Pataar
Pataar

Reputation: 661

Try

<a ng-if="$root.page == 'app'">Show Me</a>

Upvotes: 20

user3594595
user3594595

Reputation:

Do you need to use ng-if? Why not the following?

<a ng-show="$root.page == 'app'">Show Me</a>

Upvotes: 2

Related Questions