How to execute AngularJS controller function on page load?

前端 未结 14 2321
一整个雨季
一整个雨季 2020-11-22 16:04

Currently I have an Angular.js page that allows searching and displays results. User clicks on a search result, then clicks back button. I want the search results to be disp

14条回答
  •  情歌与酒
    2020-11-22 16:13

    You can do this if you want to watch the viewContentLoaded DOM object to change and then do something. using $scope.$on works too but differently especially when you have one page mode on your routing.

     $scope.$watch('$viewContentLoaded', function(){
        // do something
     });
    

提交回复
热议问题