LetsLunch / lunch

Other
38 stars 3 forks source link

do not generate markup in controllers >:| #77

Closed cameron closed 10 years ago

cameron commented 10 years ago

https://github.com/LetsLunch/lunch/blob/development/app/scripts/profile.js#L97

why not just

<div class='userimage'><img ng-src="{{ userData.photo_url }} "/></div>

and

 var getPicture = function() {
    OpenFB.get('/me/picture?redirect=0&height=133&type=normal&width=100')//'/me/picture')
    .success(function(data){
      if(data !== $scope.userData.photo_url){
        //     var image = "<div class='userimage'><img src='" + data.data.url + "'/></div>";
        //     angular.element(document.querySelector('#userimage')).html(image);
        $scope.userData.photo_url = data.data.url;
        //tell the database the image associated with the user has changed
        postUser();
        $rootScope.$emit('userDataChanged', $scope.userData);
      }
    });
  };

Ah, perhaps because of the issue I mentioned in https://github.com/LetsLunch/lunch/issues/76? OpenFB.success is surely outside the angular $digest cycle, so $scope.$apply will eliminate the need for the .html hack.