1

I got some JSON like this:

[{
    "Id": 0,
    "Text": "Item 1",
    "Selected": 1
}, {
    "Id": 1,
    "Text": "Item 2",
    "Selected": 1
}]

And an Input like this:

<input type="text"
 value="{{question.postObjs}}"

What I want is the only the property "Text" as a list in the input.

Item 1, Item 2, ...

Is this even possible? I trying around like a while, got nothing to work :-(

2 Answers 2

1

in your controller :

scope.text = '';    
for (var value in scope.question.postObjs){
    scope.text = scope.text + value.Text;
}

in your input :

<input type="text" value="{{text}}" />

or

<input type="text" ng-model="text" />
Sign up to request clarification or add additional context in comments.

Comments

0

Write a method in AngularController like this

$scope.getText(){
   // which will return ["Item1", "Item2"]
}

And in view you can use the method to populate the value.

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.