trying to add loading wheel using angular when i make ajax call?

后端 未结 4 1009
小鲜肉
小鲜肉 2021-01-26 03:03

I am trying to implement loading wheel directive when we make ajax call so during the response time i want to display loading wheen, With below code i do not see any error neith

4条回答
  •  一个人的身影
    2021-01-26 03:53

    In a nutshell, what I would do instead would be to always have the loading wheel in the view, and just use ng-if to control whether it shows or not.

    // view
    
    
    

    And then, whenever you go to load, just set vm.loading (probably this.loading depending on context) to true, and when done, false. Then the loading wheel will show up when it's ready, and go away when it's done.

    It's a lot cleaner and easier than manually showing and hiding it.

提交回复
热议问题