0

I have a form with a dropdown element. The value of the options in the select are IDs from another table. When I click save/add, I save the data to the server, and I add the data to a dynamic table under the form.

In the table I want to display the corresponding name, as in the dropdown element, but I only have the ID which was saved. What is the best method or common practices to display the name?

Example:

Dropdown:

1: Jackson Middle School
2: St Thomas High School
3: Jackson High School

Display table using ng-repeat:

{{school}} *Displays 1,2,3 not 'Jackson Middle School'
1
  • We will need to see more of your code to help you, but i suspect that you will need to modify your ng-repeat statement. Commented Apr 6, 2015 at 16:39

2 Answers 2

0

Assuming you send a GET request with the following result:

[
    {
        "Id":1,
        "Name":"Jackson Middle School"
    },
    {
        "Id":2,
        "Name":"St Thomas High School"
    },
    {
        "Id":3,
        "Name":"Jackson High School"
    }
]

and you assign this to $scope.Schools, you should be able to use it like this:

<li ng-repeat="school in Schools">{{ school.Name }}</li>
Sign up to request clarification or add additional context in comments.

Comments

0

I just created an array "school_names = [1: Jackson Middle School, 2: St Thomas High School, 3: Jackson High School]" and in the table i just did an array look up {{school_names[school]]}}

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.