MSGraph – Is it possible to slice an attribute called from an API?

0

Issue

I am using MGT (Microsoft Graph Toolkit) and was wondering if it was possible to slice an attribute.
Here is my code:

                <mgt-person person-query="me">
                  <template>
                   <div>
                    {{person.displayName}}
                   </div>
                  </template>
                <template data-type="loading">
                   Loading
                </template>
                 </mgt-person>

person.DisplayName Returns : "Smith, John"

How do just get the first name from this? I want to slice out the last name and the ",".

I know {{person.givenName}} will give you the first name but for various reasons, some users have a different name in their display name they prefer to be called by.

Please help.

Solution

You could use js to achieve this:

person.displayName.split(",")[0]

Answered By – Michael Han_MSFT

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More