1

I'm new to Angular so it's probably something easy I'm struggling with.

Here's the JSON with the data:

[
     {
        "date"      : "2016-02-12T20:30:00",
        "duration"  : 60,
        "supervisor": {
            "name"           : "Anna",
            "surname"        : "Nowak",
            "supervision_fee": "140.00"
        }
    }
]

I'm feeding this into a select element like this:

<select name="meetingSelect" 
    ng-model="meeting.active" 
    ng-options="meeting.id as meeting.date|date:'dd.MM.yy' + ' '+ meeting.supervisor.name + ' '+meeting.supervisor.surname for meeting in scheduledMeetings" 
    ng-change="" class="form-control">
</select>

What I get however in my HTML code is the following: 12.02.16 AnnPM No6PMK

Seems that Angular must be escaping (?) some characters (like out of 'a' we get 'PM')...

Why is this happening and what to do about that?

Thanks!

2 Answers 2

2

Your expression is being interpreted as:

meeting.date|date:(
   'dd.MM.yy' + ' '+ meeting.supervisor.name + ' '+meeting.supervisor.surname)

so:

meeting.date|date:'dd.MM.yy Anna Nowak'

which is a very strange format string for a date.

Sign up to request clarification or add additional context in comments.

Comments

1

It thinks that the name you're printing is part of the date format. Try using parenthesis in ng-options.

ng-options="meeting.id as (meeting.date|date:'dd.MM.yy') + ' '+ meeting.supervisor.name + ' '+meeting.supervisor.surname for meeting in scheduledMeetings"

Your format was interpreted as meeting.date|date:'dd.MM.yy Anna Nowak' where some characters like a have special meaning.

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.