2

내가이 코드를 사용하면 내가 asp mvc 5페이지 2 앵귤러 및 ASP에서 찾을 수 없습니다

때 작동하지 않고 문제가없는 각도 2를 사용했습니다.

app.module :

import { NgModule } from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 

import { AppComponent } from './app.component'; 
@NgModule({ 
    imports: [BrowserModule], 
    declarations: [AppComponent], 
    bootstrap: [AppComponent] 
}) 
export class AppModule { } 

app.component

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

@Component({ 
    selector: 'my-app', 
    template: '<h1>My First App</h1>' 
}) 
export class AppComponent { 
} 

및 헤더

:

<head> 
<meta charset="utf-8" /> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>@ViewBag.Title - My ASP.NET Application</title> 
<base href="/" /> 
<link rel="stylesheet" href="/styles.css"> 
<!-- Polyfill(s) for older browsers --> 
<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> 
@Styles.Render("~/Content/css") 
@Scripts.Render("~/bundles/modernizr") 

이 코드는 작업입니다. 보기에 나를 보여줍니다 : My First App.

하지만 난이 코드를 사용할 때 그것은 나에게 오류를 보여

app.module :

import { NgModule } from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 

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

@NgModule({ 
    imports: [BrowserModule], 
    declarations: [AppComponent, OtherComponent], 
    bootstrap: [AppComponent] 
}) 
export class AppModule { } 

app.component :

import { Component } from '@angular/core'; 
import { OtherComponent } from './other/other.component'; 

@Component({ 
    selector: 'my-app', 
    template: `<h1>My First App</h1> 
       <other-app></other-app> 
` 
}) 
export class AppComponent { 
} 
내가이 코드를 사용

Error

other.component :

10 other.component.html :

<div class="panel panel-default"> 
    <div class="panel-body"> 
     {{name}} 
    </div> 
</div> 

무슨 문제? 이 문제를 어떻게 해결할 수 있습니까?

답변

1

templateUrl: 'app/other/other.component'

'app/other/other.component.html' 
에 .html 중에서 형식을 추가
관련 문제