最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - AngularJS ng-if for $rootScope - Stack Overflow

programmeradmin0浏览0评论

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>

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>
Share Improve this question asked Jul 7, 2014 at 14:09 ngplaygroundngplayground 21.6k37 gold badges98 silver badges174 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 20

Try

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

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

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

发布评论

评论列表(0)

  1. 暂无评论