Reputation: 103
I'm using Ionic framework to create my app.
I have a text input, with ng-model="answer"
, and bellow a have a button that starts speech recognition and then replaces the input text with the spoken one.
The problem is that I can't change the input's text programmatically when using the mic with $scope.answer="any text"
, it looks like it just doesn't change the view's value.
I found that I have to use a directive in order to bind the model, but to be honest I don't know how to address it right now.
Also I've tried $scope.$apply()
but it works only the first time and when I haven't wrote any test directly to the input yet.
Upvotes: 0
Views: 217
Reputation: 3907
What you are looking for may be Angulars $watch()
function, so you can handle any model changes even outside of the input field.
https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$watch
Upvotes: 1