1

I have a list

$scope.options = [
    { id:1, val: "Item 1"},
    { id:2, val: "Item 2"},
    { id:3, val: "Item 3"}
];

I want to be able to generate a list of xml elements

    <Name>{{option.id}}</Name>
    <Value>{{option.val}}SAS</Value>

I want to be able to generate it inside a text area

   <textarea>
    // some kind of loop here
    <Name>{{option.id}}</Name>
    <Value>{{option.val}}SAS</Value>
   </textarea>

The ng-repeat element seems to require to be in some of type of element such as option, div, etc.

This won't work for me. I need it to simply generate text strings inside a textarea.

Could someone please provide an example?

2
  • Might have to construct that manually and append it to the textarea Commented Oct 7, 2013 at 17:40
  • I need to be able to use ng-repeat inside a textarea. Anyone know how to do that? Commented Oct 7, 2013 at 17:47

1 Answer 1

2

Well, a custom function in your controller might help:

$scope.xmlGenerator = function() {
    var xml = "";
    angular.forEach($scope.options, function(key, value) {
        xml += "<Name>" +value.id+"</Name><Value>" + value.val + "SAS</Value>";
    }
}

And in your textarea

<textarea>{{xmlGenerator()}}</textarea>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.