I'm making an async call to a speech recognition API and try to store the result in a $scope variable, but the view doesn't change, even though the results show up in console.log
just fine. I tried using $scope.$apply()
and $scope.applyAsync();
as suggested in these threads - this and this, unfortunately with no effect
Here's what controller looks like:
myApp.controller('audiotest', function($scope)
{
$scope.recognize = function(){
speech.main('test.wav', function(err, res){
$scope.myResult = res.results[0].alternatives[0].transcript;
console.log($scope.myResult); // <- this logs correctly
$scope.$applyAsync(); // also tried with $scope.$apply();
});
};
};
I don't think the markup is relevant, but here it is, anyway:
<div class="row" ng-controller="audiotest">
<div class="row">
<button type="button" ng-click="recognize()"> Attempt recognition </button>
<p> Result is {{myResult}} </p>
</div>
</div>
Thanks in advance for any input or ideas.