Angular 未使用角度选择器呈现Html内容

Angular 未使用角度选择器呈现Html内容,angular,asp.net-mvc-5,Angular,Asp.net Mvc 5,我正在开发一个角度为2/4的应用程序,在主index.cshtml页面中呈现app.component.html时遇到问题。但是,我只能看到index.cshtml页面中硬编码的单词加载。我的模板url路径是否有任何问题,或者我是否遗漏了什么。我已经检查了开发工具,没有发现任何错误 应用程序组件.ts import { Component} from '@angular/core' @Component({ selector: 'mrdb-app', templateUrl

我正在开发一个角度为2/4的应用程序,在主index.cshtml页面中呈现app.component.html时遇到问题。但是,我只能看到index.cshtml页面中硬编码的单词加载。我的模板url路径是否有任何问题,或者我是否遗漏了什么。我已经检查了开发工具,没有发现任何错误

应用程序组件.ts

import { Component} from '@angular/core'


@Component({

    selector: 'mrdb-app',
    templateUrl : './app.component.html'

})


export class AppComponent {

    pageTitle: string = "Movies Review Database";

}
应用程序模块.ts

import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { BrowserModule } from '@angular/platform-browser';


@NgModule({
    imports: [BrowserModule],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})

export class AppModule {

}
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);
/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
    System.config({        
        paths: {
            // paths serve as alias
            'npm:': '/libs/'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder
            app: '/Scripts',
            // angular bundles
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
            // other libraries
            'rxjs': 'npm:rxjs',
            'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: './main.js',
                defaultExtension: 'js',
            },
            rxjs: {
                defaultExtension: 'js'
            }
        }
    });
})(this);
app.component.html

<h1>Angular 2 : Getting Started</h1>>
@{
    ViewBag.Title = "Home Page";
}

<mrdb-app>Loading...</mrdb-app>
systemjs.cofig.js

import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { BrowserModule } from '@angular/platform-browser';


@NgModule({
    imports: [BrowserModule],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})

export class AppModule {

}
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);
/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
    System.config({        
        paths: {
            // paths serve as alias
            'npm:': '/libs/'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder
            app: '/Scripts',
            // angular bundles
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
            // other libraries
            'rxjs': 'npm:rxjs',
            'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: './main.js',
                defaultExtension: 'js',
            },
            rxjs: {
                defaultExtension: 'js'
            }
        }
    });
})(this);
index.cshtml

<h1>Angular 2 : Getting Started</h1>>
@{
    ViewBag.Title = "Home Page";
}

<mrdb-app>Loading...</mrdb-app>
@{
ViewBag.Title=“主页”;
}
加载。。。

尝试添加
module.id
,以便在组件中使用相对路径,如下所示:

@Component({
moduleId: module.id,
selector: 'mrdb-app',
templateUrl: 'app.component.html',
})
export class AppComponent {}

或者最好使用
systemjs angular loader.js
并使用相对路径,而不使用
modueId

尝试添加
module.id
,以便在组件中使用相对路径,如下所示:

@Component({
moduleId: module.id,
selector: 'mrdb-app',
templateUrl: 'app.component.html',
})
export class AppComponent {}

或者最好使用
systemjs angular loader.js
并使用根本没有
modueId
的相对路径。

我已经解决了这个问题。问题是我试图直接调用App.Module.js,而不是在layout.cshtml页面中调用main.js。main.js负责引导app.module并启动加载。

我已经解决了这个问题。问题是我试图直接调用App.Module.js,而不是在layout.cshtml页面中调用main.js。main.js负责引导app.module并启动加载。

你的
index.cshtml
看起来怎么样?是的。更新了可放置调试器的假定。我在开发者的source选项卡中看不到main.js,也不确定问题出在哪里,因为我看不到任何错误你的
index.cshtml
看起来怎么样?是的。更新了可放置调试器的假定。我在开发者的source选项卡中看不到main.js,也不确定问题是什么,因为我看不到任何错误。你能分享systemjs-angular-loader.js的外观吗?我添加了systemjs-angular-loader.js,但没有区别。你能分享systemjs-angular-loader.js的外观吗?我添加了systemjs-angular-loader.js,但没有区别