我是AngularJS的新手,似乎在解決如何自定義ng-show/ng-hide時遇到了問題。我希望下面的粘貼導航欄出現,一旦用戶在頁面上滾動600px。因爲我不能使用jQuery與角度,我有點困惑如何添加此功能。如何在頁面上實現基於位置的ng顯示
我目前正在連接到一個auth控制器,它有很多不相關的代碼,我沒有發佈它。
<nav ng-hide="true" class='homeNoAuth'>
<span class='nav navbar-fixed-top'>
<h1 id='homeLogo' ui-sref='home'>Title</h1>
<span class='navElement' ui-sref='signin'>Log In</span>
<span class='navElement' ui-sref='signup'>Sign Up</span>
<span class='navElement' ui-sref='about'>About</span>
<span class="search input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
</button>
</span>
</span>
</span>
</nav>
任何建議將是驚人的。謝謝!
耶!這個反應很驚人。如此簡單,優雅和愛,它迫使我使用自定義指令,我不需要害怕。非常感謝! –
很高興爲你效勞。爲了使指令更清潔一點,if/else可以用三元代替... scope.showContent = this.pageYOffset> = 600?真假; – buzzsaw