Angular 回到顶部 滚动到特定的页面位置

$timeout(function() {
                // $location.hash('bottom');
                // $anchorScroll();

                // var a=angular.element("#loginPage")[0].scrollTop;
                // var b=angular.element("#loginPage")[0].scrollHeight;
                // angular.element("#loginPage")[0].scrollTop=b;

                var height = $("#loginPage").outerHeight()-110;
                var width = $("#loginPage").outerWidth()-260;
                $('body, html').animate({
                    "scrollTop" : height,
                    "scrollLeft" : width
                }, 500);
            })
<!-- Top content -->
<div ng-controller="YacmpLoginController">
<div id="loginPage" class="top-content"  style="position: static;background-image: url(libs/img/backgrounds/ClearingHouseBg.png);">
        <div class="container" style="width: 100%;">
            <div class="row">
                <div class="col-sm-12 form-box">
                    <div class="form-bottom">
                        <form role="form" action="login" method='POST' autocomplete="off" name="loginForm" novalidate>
                            <div style="padding-left: 192px;">
                                <span class="error"  ng-show="errorMessage != null">{{errorMessage|translate}}</span>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-4 control-label">{{'User Id/Email'|translate}}:</label>
                                <!--<label class="sr-only" for="form-email">{{'User Id/Email'|translate}}</label>-->
                                <div class="col-sm-5">
                                    <input type="text" name="username" ng-model="username"  class="login-form-control" placeholder="{{ 'User Id/Email' | translate}}" id="form-email" required autocomplete="off"/>
                                    <span class="error" ng-show="for.username.$error.required">
                                        {{'Please input user id or email'|translate}}
                                    </span>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-4 control-label">{{'Password'|translate}}:</label>
                                <div class="col-sm-5">
                                    <input type="password" name="plainPwd" ng-model="password" class="login-form-control" placeholder="{{ 'Password' | translate}}" required autocomplete="off">
                                    <input hidden name="password" value="{{passwordHash}}" />
                                    <input hidden name="encrypted" value="{{isEncrypted}}" />
                                    <input hidden name="loginType" value="{{loginType}}" />
                                </div>
                                <!--<div class="col-xs-6">-->
                                <!--<input type="checkbox" class="login-form-control"/>-->
                                <!--{{'Remember me'|translate}}-->
                                <!--</div>-->
                                <!--<div class="col-xs-1 pull-right">-->
                                <!--<a class="float-right" ng-href="#/register">{{'register'|translate}}</a>-->
                                <!--</div>-->
                                <div class="col-sm-2">
                                    <a ng-click="forgetPassword()">{{'Forget Password'|translate}}</a>
                                </div>
                            </div>

                            <div class="row">
                                <div>
                                    <button type="submit" name="submit" value="Login" class="btn btn-primary btn-block btn-flat">{{'Sign in'|translate}}</button>
                                </div>
                            </div>

                            <div class="form-group row">
                                <!--<select class="login-form-control" ng-model="selectedTenant" ng-options="t.name for t in all_tenants" required ng-disabled="all_tenants.length===1">-->
                                <!--</select>-->
                                <input hidden name="tenant" value="{{selectedTenant}}" />
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    <a id="bottom"></a>
</div>
</div>

 

posted @ 2017-06-02 14:46  画梦笙箫  Views(2327)  Comments(0Edit  收藏  举报