0

i using angular 2 in asp mvc 5 .

i need to show <my-app> </my-app> content in view .

app.component :

import { Component } from '@angular/core';
import 'rxjs/Rx';   // Load all features
import { ROUTER_PROVIDERS, RouteConfig, ROUTER_DIRECTIVES } from '@angular/router';

import { OtherComponent } from './other/other.component';

@Component({
    selector: 'my-app',
    template: `<h1>My Name is {{name}}</h1>
    <other-app></other-app>`,
})
@RouteConfig([
    { path: '/other', name: 'other', component: OtherComponent }
])
export class AppComponent {

    name = "Kianoush";
}

it show error to me :

Severity Code Description Project File Line Suppression State Error Build:Module '"F:/MyProject/angfinal/angfinal/node_modules/@angular/router/index"' has no exported member 'ROUTER_PROVIDERS'. angfinal F:\MyProject\angfinal\angfinal\app\app.component.ts 3

.

Severity Code Description Project File Line Suppression State Error Build:Module '"F:/MyProject/angfinal/angfinal/node_modules/@angular/router/index"' has no exported member 'RouteConfig'. angfinal F:\MyProject\angfinal\angfinal\app\app.component.ts 3

.

Severity Code Description Project File Line Suppression State Error TS2305 Module '"F:/MyProject/angfinal/angfinal/node_modules/@angular/router/index"' has no exported member 'ROUTER_PROVIDERS'. TypeScript Virtual Projects F:\MyProject\angfinal\angfinal\app\app.component.ts 3 Active

.

Severity Code Description Project File Line Suppression State Error TS2305 Module '"F:/MyProject/angfinal/angfinal/node_modules/@angular/router/index"' has no exported member 'RouteConfig'. TypeScript Virtual Projects F:\MyProject\angfinal\angfinal\app\app.component.ts 3 Active

.

other.component :

import { Component } from '@angular/core';

@Component({
    selector: 'other-app',
    templateUrl: './app/other/other.component.html'
})
export class OtherComponent {
    name = "kianoush";
}

and header :

<head>
<base href="/">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
<link href="~/Content/Site.css" rel="stylesheet" type="text/css" />
<link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="~/Scripts/modernizr-2.6.2.js"></script>
<script src="/node_modules/core-js/client/shim.min.js"></script>
<script src="/node_modules/zone.js/dist/zone.js"></script>
<script src="/node_modules/reflect-metadata/Reflect.js"></script>
<script src="/node_modules/systemjs/dist/system.src.js"></script>
<script src="/systemjs.config.js"></script>
<script>
  System.import('app').catch(function(err){ console.error(err); });
</script>

and config :

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
        routes.MapRoute(
            name: "NotFound",
            url: "{*catchall}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}

and how can i show other.component.html in View and how can i solve this problem ??

2
  • you should focus on this line according the errormessage “import 'rxjs/Rx'”; Commented Mar 11, 2017 at 10:24
  • @Pengyy i remove this line but still show me error Commented Mar 11, 2017 at 10:29

1 Answer 1

1

It seems you have used older angular 2 router providers and services. if you have to use older version you should use router-deprecated. otherwise use new syntax described in angular documentation

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

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.