我的angularJS Webapp存在两个主要问题。
我希望浏览器在滚动到顶部时 路线是chaning(或页面正在改变) - 目前 它记住了这个位置 - 这有点令人讨厌。
我在子页面上有一个包含3个不同标签的页面。 我可以使用ng-click功能和smoth滚动(锚点)
我的问题是,我希望这个锚标签显示在网址中 喜欢:about / section1 about / section2 about / section3
目前所有人都住在“约”
这是我的设置:
// 3 Ng click funtions to navigate in the submenue to the sections (all in one page) - but they not showing up in the url tag!
angular.module('testApp')
.value('duScrollDuration', 2000)
.value('duScrollOffset', 122)
.controller('ankerCtrl', function($scope, $document){
var container = angular.element(document.getElementById('container'));
$scope.toTheTop = function() {
container.scrollTop(0, 5000);
}
$scope.toSection1 = function() {
console.log("hallooo ich will zu section 1");
var someElement = angular.element(document.getElementById('section-1'));
$document.scrollToElementAnimated(someElement);
}
$scope.toSection2 = function() {
console.log("hallooo ich will zu section 2");
var someElement = angular.element(document.getElementById('section-2'));
$document.scrollToElementAnimated(someElement);
}
$scope.toSection3 = function() {
console.log("hallooo ich will zu section 3");
var someElement = angular.element(document.getElementById('section-3'));
$document.scrollToElementAnimated(someElement);
}
}
);
//Routing
.config(function ($urlRouterProvider, $stateProvider, $anchorScrollProvider) {
$stateProvider
.state('about', {
url: "/about",
views: {
'content': {
templateUrl: 'views/about.html',
controller: 'MainCtrl'
},
'subnavi': {
templateUrl: 'views/subnavi-about.html'
}
}
}).state('unternehmen', {
url: "/unternehmen",
views: {
'content': {
templateUrl: 'views/unternehmen.html',
controller: 'MainCtrl'
},
'subnavi': {
templateUrl: 'views/subnavi-unternehmen.html'
}
}
})
.state('main', {
url: "/",
views: {
'content': {
templateUrl: 'views/main.html'
}
}
});
$urlRouterProvider.otherwise('/');
$anchorScrollProvider.disableAutoScrolling();
});
非常感谢您的帮助!
(再次: 1.滚动到顶部 2. subanchors不会出现在url标签
中