We are trying to implement like below requirement. Click of a button some text will be generated and it will be added into textarea. Button is using Ng-Onclick.
Button Code is below.
<input type="submit" value="Add to form" class="btn btn-primary" ng-click="addToFormID($index)" />
But many buttons will be there like if am adding 4 components 4 buttons will be there to generate the formula.
and Here is my TextArea Code:
<textarea id="summarFormula" ng-model=".Summarisation" ng-change="setSummarisationFormulaDynamic()" cols="100" rows="4"></textarea>
and Here is my Script.
$scope.addToFormID = function(index){
if( $scope.vm.SummarisationForm==null)
{
$scope.vm.SummarisationForm ="["+ $scope.vm.Dependencies[index].NeName+":{"+$scope.vm.Dependencies[index].DbId+","+$scope.vm.Dependencies[index].VersionId+"}]";
}else
$scope.vm.Summarisation+="["+ $scope.vm.Dependencies[index].Name+":{"+$scope.vm.Dependencies[index].Id+","+$scope.vm.Dependencies[index].VersionId+"}]";
$scope.setSummarisationFormDynamic();
}
We can see that in else part $scope.vm.SummarisationForm += so it will + the next formula to previous one so i wants to modify this one and needs to add the content where i am keeping the cursor.
Now What ever I am clicking it is adding it to the end of the content , If am entering enter key keeping cursor into first line of the next line also it is adding it to the same line which already text is there so i wants to find the cursor position and insert into the text where exactly keeping cursor or entering enter key position.
I am very new to angular js so please help me with basic idea with button how can i implement and script modification how can i do it.?
Edit : It is ASP.NET MVC5 Applicaiton.
If you need further more details please let me know.
Thanks in advance to all.