Scroll to top of div in AngularJS?

前端 未结 4 829
情深已故
情深已故 2021-02-03 18:39

I am using AngularJS for a small web app and have encountered a problem. I am using ng-repeat to populate a list inside of a div. The div has a fixed height and is

4条回答
  •  伪装坚强ぢ
    2021-02-03 19:15

    I have faced the same issue with table body scrolling. I have resolved it in following way.

    Here is my sample html.

    ....
         //this is the data
                .....
            

    Here is the angular code to scroll to the top

    
    

    I hope it helps.
    You can put this script in required function, so when particular things happen it get triggered automatically. Or can be attached to event also.

    For div element this can be done in following way

    http://plnkr.co/edit/0B4zrFTho6GYuPAS0S1A?p=preview

    Thanks.

提交回复
热议问题