0

How can I use angular 2 and razor views to get to

<my-component [items]= @Model.Items ></my-component>

Model is a Mvc.net.

I am using typescript. Component templates are inline and not using template url

At help appreciated

2 Answers 2

3

You can't easily do this. This was something you could do with Angular1.

Use Asp.net WebAPI to expose your models to your Angular app through a stateless Rest API service instead.

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

Comments

0
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `    
<h2>My favorite skill is: {{myskills}}</h2>
<p>Skill:</p>
<ul>
  <li *ngFor="let skl of skills">
    {{ skl }}
  </li>
</ul>
`
})

export class AppComponent {
    title = 'ASP.NET MVC 5 with Angular 2';
    skills = ['MVC 5', 'Angular 2', 'TypeScript', 'Visual Studio 2015'];
    myskills = this.skills[1];
}

http://www.mithunvp.com/using-angular-2-asp-net-mvc-5-visual-studio/ And checkout this link for the github project per the link above.

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.