I am attempting to send the values of two input boxes to a single controller function.
<div class="container" ng-controller="MainCtrl">
<div class="row">
<div class="col-lg-6">
<input type="text" name="regex" class="form-control" placeholder="Regex"
ng-model="do_parsing.data"
ng-model-options="{ getterSetter: true }">
</div>
<div class="col-lg-2">
<input type="text" name="modifier" class="form-control" placeholder="modifier">
</div>
</div>
<hr>
<div class="form-group">
<textarea class="form-control" id="input_data" rows="10" style="width: 555px; height: 214px"
placeholder="Insert your test string here"
ng-model="do_parsing.data"
ng-model-options="{ getterSetter: true }"></textarea>
</div>
<div class="form-group">
<pre> <span ng-bind="do_parsing.data()"></span></pre>
</div>
</div>
This is my controller.js
file,
app.controller('MainCtrl', function ($scope) {
var _data = '';
$scope.do_parsing = {
data: function(newData) {
if (newData != undefined) {
alert(newData);
}
return arguments.length ? (_data = newData) : _data;
}
};
});
I aim to pass the values of the first input box and the text area to the do_parsing
function. I want the function to then return the parsed data to the pre
tag. Essentially, this do_parsing
function should be triggered whenever the value of the first input box and the text-area
changes. I have attempted the above approach, but it displays the same value in all three places.