SP1
SP1

Reputation: 1202

Using angular variable inside MVC razor view

Can someone please tell me how I can use angularJS variable in the below statements. So Instead of scenario.InterestRate I want to add a angular variable {{x.rate}} and in place of scenario.Rate I want {{x.flat}}

<td class="text-right">
                    @String.Format("{0:F4}", scenario.InterestRate)
                </td>
              @if (scenario.Rate != null) 

Thanks

Upvotes: 1

Views: 629

Answers (1)

w.brian
w.brian

Reputation: 17397

What you're trying to do isn't possible. Razor templates are executed server-side, before they reach the browser -- which is where angular runs.

It looks like your intention is to use razor to format the value coming from angular. The appropriate way to do this would be to use angular filters, specifically the number formatter.

<td class="text-right">
    {{x.rate | number:4}}
</td>

Upvotes: 2

Related Questions