AngularJS ng-if for $ rootScope

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

in my controller $rootScope.page = 'app' as well as $scope.page = 'app' , but when I use the following in my DOM, it does not appear when I am on this page.

 <a ng-if="page == 'app'">Show Me</a> 
+7
javascript angularjs angularjs-scope
source share
2 answers

Try

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

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

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

+2
source share

All Articles