i set div background setpic()
function. use changepic()
function update picture
html
div.profileimg(id="img", ng-style="imagepath")
angular/js
function setpic() { console.log("in set pic") var url = '/api/image?spotid=' + $window.sessionstorage.getitem("currentgarage") $http.get(url).then( function successcallback(response) { console.log("success image") $scope.imagepath = {}; $scope.imagepath = { background: 'url(' + url + ')' }; }, function errorcallback(response) { console.log("fail image") }); } changepic = function(fd) { url = "/api/spot/pic/post?spotid=" + $window.sessionstorage.getitem("currentgarage"); $http.post(url, fd, { headers: { 'content-type': undefined }, transformrequest: angular.identity }).then( function successcallback(response) { console.log("success post image") setpic(); }, function errorcallback(response) { console.log("fail post image") }); };
the setpic()
function called once @ beginning of controller (works), , once inside success clause of changepic()
function. why calling setpic()
after page load not work?
one more question. notice how define functions differently. 1 function name()
, other name = function()
. setpic()
called controller , not dom. if change form of function site not build , see {{}}
in fields. changepic()
registered in onclick
of button , if change form of function, click not register. mind-blowing craziness here. should go take javascript/angular course before attempting code anymore?
Comments
Post a Comment