Hello! I am currently working on creating a directive to pass a value to my ng-model. Within my directive, there is a controller and I would like to pass the value from it to my ng-model.
Let's assume I have a string value, when I click on $scope.speakUP, it should be passed onto the ng-model.
.directive('speak', function(){
return {
restrict: 'A',
require: 'ngModel',
scope: true,
template: '<i ng-click = "speakUP()" class="icon ion-mic-a larger"></i>',
controller: function($scope, $element){
$scope.speakUP = function(){
$scope.passThisString = "Sample Data";
}
}
Here is my HTML code:
<input type="text" ng-model="sampleModel" speak>