AngularJS update View after Model loaded from Ajax

前端 未结 4 661

I\'m newbie of angularjs developing and i wrote this simple app, but don\'t understand how i can update view, after the model il loaded from ajax request on startup!

4条回答
  •  一生所求
    2020-12-28 22:14

    You need to bind an element in your view to a property (simple or object) of your $scope object. Once the $scope object is updated the view should be updated on its own. That is the beauty of AngularJS.

    EDIT: Please register your controller as

    photoAppModule.controller('listCtrl', function($scope){
      $scope.photos = photos;
    
    });
    

    If photos variable is not available, then you might have to create a service with the variable and inject in the controller.

提交回复
热议问题