【发布时间】:2015-11-21 03:10:49
【问题描述】:
我正在使用Ionic framework 并正在寻找非jquery 粘性菜单插件,这时我发现了ngSticky。
bower install ngSticky
很棒的插件,包含的演示文件显示它运行良好,只需将sticky 属性添加到您想要粘贴的任何 div 中。
问题是,由于某种原因,它无法在 Ionic framework 的我的 <ion-nav-view> <ion-content> 部分内工作。
这是我的演示链接:
http://leongaban.com/sticky/#/
当你向下滚动时,灰色的标题栏应该会粘住。
如果 HTML 只是在正文中而不是在 ion-nav-view 内呈现,它确实会保留。
<header class="social-media-header" sticky>
<div class="feed-type">Sticky Header</div>
<div class="social-filter">
<div class="social-latest">Tweets</div>
</div>
</header>
<body ng-app="demo" ng-controller="demoCtrl">
<ion-nav-view></ion-nav-view>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.4/angular.js"></script> -->
<script src="ionic.bundle.min.js"></script>
<script src="sticky.min.js"></script>
<script>
var app = angular.module('demo', [
'ionic',
'sticky'])
// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('/', {
url: "/",
templateUrl: "home.html",
controller: 'demoCtrl'
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/');
})
.controller('demoCtrl', function($scope) {
// $scope.disableSticking = false;
console.log('demoCtrl');
});
</script>
</body>
还有其他人遇到过类似的问题吗?在模板中使用类似的 AngularJS 粘性菜单插件?
【问题讨论】:
标签: javascript angularjs angularjs-directive ionic-framework ionic