Search code examples
javascriptangularjssalesforcevisualforce

Angular JS unable to display a field when the result is retrieved from salesforce


I have used AngularJS while developing a visual force page and was trying to create a record under a custom object, I could see that the Salesforce controller is returning the ID to javascript callback function and am using

$scope.lblMsg={value:result['message']}

inside the success condition but I was unable to populate that into a label field and label field isn't displayed, whereas when I use

document.getElementById('lblMsg').innerHTML=result['message'];

I was able to display the message.

Can you please suggest what might be the mistake using AngularJS ? and also specify any effective solution to perform the task with AngularJS.

Please find the link below where the above form is hosted

http://ganeshforce-developer-edition.ap2.force.com/


Solution

  • Are you using $scope.lblMsg={value:result['message']} inside a callback fro ma 3rd party api, like salesforce instead of a normal $http call? If 'yes', then you should consider wrapping that in an $apply block or an $applyAsync one, otherwise Angular won't know about that update.