If you must do that, you can always tie a hidden input to angular using ng-model, and onload use your 'showMessage' method to populate that input. Angular will then have that data stored wherever ng-model told it to be stored.
HTML:
<input id="myMessage" type="hidden" value="" ng-model="myMessage"/>
Script Tag:
<script>
function showMessage(message) {
console.log("message type is" +message.type);
var response = document.getElementById('response');
var p = document.createElement('p');
p.style.wordWrap = 'break-word';
p.appendChild(document.createTextNode(message));
response.appendChild(p);
// not sure what all the above is doing, but assuming message is just a string, do this...
setTimeout(function() {
document.getElementById('myMessage').value = message;
});
}
</script>
Angular Code:
.controller($scope, function($scope) {
$scope.myMessage;
var myInt = setInterval(function() {
if (document.getElementById('myMessage').value !== '') {
$scope.myMessage = document.getElementById('myMessage').value;
$scope.$apply();
clearInterval(myInt);
}
}, 150);
});
While this is kind of hacky, it works.
However, I would do what @GandalftheWhite said. Gandalf is always
right ;)
https://jsfiddle.net/jvincilione/cft3reo3/