想不通底部为什么页面加载?角UI的路由器自动滚动发行 [英] Can't figure out why page loads at bottom? Angular UI-Router autoscroll Issue

查看:114
本文介绍了想不通底部为什么页面加载?角UI的路由器自动滚动发行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我的生活,我想不通,为什么在底部这个主页负载。这是一个角度的UI路由器,棱角分明,JavaScript或CSS问题?我一直停留在这两个小时,不知道为什么我的html页面加载在底部而非顶部真是笑死我的自尊作为一个程序员:/

下面是主页:[URL绝密]

更新 -
我解决了这个问题。正是有了角UI的路由器。见下面的简单的修复我的答案。

我用角和角度UI的路由器和设​​置看起来像这样...

default.jade

  DOCTYPE HTML
  HTML(LANG =EN,的xmlns =HTTP://www.w3.org/1999/xhtml',的xmlns:FB =的https://www.facebook.com/2008/fbml'中的itemscope ='的itemscope ',项目类型=HTTP://schema.org/Product')
  包括../includes/head
  体(NG-控制器=RootController)
  块内容
  包括../includes/foot

index.jade

 扩展布局/默认块内容
  section.container
    DIV(UI视图=头)
    DIV(UI视图=内容)
    DIV(UI视图=页脚)

角Config.js

  window.app.config(函数($ stateProvider,$ urlRouterProvider){
//对于任何无与伦比的url,重定向到/
$ urlRouterProvider.otherwise(/);
//现在设置状态
$ stateProvider
    .STATE('家',{
      网址:/,
      观点:{
        头:{templateUrl:意见/头/ home.html做为},
        内容:{templateUrl:意见/内容/ home.html做为},
        页脚:{templateUrl:意见/页脚/ footer.html}
      },
      解析:{工厂:setRoot}
    })
    .STATE('登入',{
      网址:/登入
      观点:{
        头:{templateUrl:意见/头/ signin.html},
        内容:{templateUrl:意见/内容/ signin.html},
        页脚:{templateUrl:意见/页脚/ footer.html}
      },
      解析:{工厂:setRoot}
    })


解决方案

角UI-路由器最近更新了它的应用程序,以便它会自动向下滚动到默认加载新的看法。这是导致我的应用程序的页面载入向下滚动。要关闭此功能只需将以下属性添加到您的用户界面视图:

 <格UI视图=头自动滚动=真>< / DIV>

For the life of me, I cannot figure out why this home page loads at the bottom. Is this an angular ui-router, angular, javascript or CSS issue? I've been stuck on this for two hours and not knowing why my html page loads at the bottom instead of the top is really killing my self-esteem as a programmer :/

Here is the home page: [ URL Redacted ]

UPDATE -- I solved this issue. It was with Angular UI-Router. See my answer below for the simple fix.

I use Angular and Angular UI-Router and the set up looks like this...

default.jade

  doctype html
  html(lang='en', xmlns='http://www.w3.org/1999/xhtml', xmlns:fb='https://www.facebook.com/2008/fbml', itemscope='itemscope', itemtype='http://schema.org/Product')
  include ../includes/head
  body(ng-controller="RootController")
  block content
  include ../includes/foot

index.jade

extends layouts/default

block content
  section.container
    div(ui-view="header")
    div(ui-view="content")
    div(ui-view="footer")

Angular Config.js

window.app.config(function($stateProvider, $urlRouterProvider) {
// For any unmatched url, redirect to "/"
$urlRouterProvider.otherwise("/");
// Now set up the states
$stateProvider
    .state('home', {
      url: "/",
      views: {
        "header":    { templateUrl: "views/header/home.html"   },
        "content":   { templateUrl: "views/content/home.html"  },
        "footer":    { templateUrl: "views/footer/footer.html" }
      },
      resolve: { factory: setRoot }
    })
    .state('signin', {
      url: "/signin",
      views: {
        "header":    { templateUrl: "views/header/signin.html"   },
        "content":   { templateUrl: "views/content/signin.html"  },
        "footer":    { templateUrl: "views/footer/footer.html" }
      },
      resolve: { factory: setRoot }
    })

解决方案

Angular UI-Router recently updated it's app so that it automatically scrolls down to new views loaded by default. This was causing my app's pages to load scrolled down. To turn this off simply add the following attribute to your ui-view:

<div ui-view="header" autoscroll="true"></div>

这篇关于想不通底部为什么页面加载?角UI的路由器自动滚动发行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆