So this is my controller:
translateApp.controller('translateCtrl', function ($scope, $http) {
$scope.spinner = false;
$scope.talkButton = true;
function redirectRecognizedTextOutput() {
artyom.redirectRecognizedTextOutput((recognized, isFinal) => {
if (isFinal) {
// scope can't be read
$scope.talkButton = true;
$scope.spinner = false;
} else {
console.log("wait")
}
});
}
$scope.start = function () {
// I set spinner and talkButton values and call the function
$scope.spinner = true;
$scope.talkButton = false;
redirectRecognizedTextOutput()
}
})
And my problem is that the $scope.spinner
and $scope.talkButton
doesn't work as expected. I tried putting it before the promise and it works. So I tried something like
function redirectRecognizedTextOutput() {
var vm = this
artyom.redirectRecognizedTextOutput((recognized, isFinal) => {
if (isFinal) {
vm.spinner = false;
vm.talkButton = true;
} else {
console.log("wait")
}
});
}
But still no changes and no errors. Am I doing it wrong? Any help would be much appreciated.
this
!=$scope
? Where exactly do you expect the angular scope to come from (It's not a global variable)?