为什么我的应用组件呈现应用组件
Why Does My App Component Render an App Component?
经验丰富的 Angular 1 开发人员试图学习 Angular 2。我有一个行为奇怪的准系统应用程序。我正在使用MeteorJS来提供一切。这是应用程序结构-
client/
components/
articles/
articles.component.html
articles.component.ts
index.html
app.html
app.ts
索引.html -
<template>
<app></app>
</template>
应用程序.html -
<template>
<nav>
<ul>
<li>
<a [routerLink]="['Articles']">Articles</a>
</li>
<li>Nav 2</li>
<li>Nav 3</li>
<li>Nav 4</li>
</ul>
</nav>
<section>
<router-outlet></router-outlet>
</section>
</template>
应用程序 -
import {Component, View} from 'angular2/core';
import {bootstrap} from 'angular2-meteor';
module WSN.App {
@Component({
selector: 'app',
templateUrl: 'app.html'
})
export class AppComponent {
}
bootstrap(AppComponent);
}
除非有要求,否则我不会显示文章文件。我得到的是这个html-
<body>
<app>
<html>
<head>
</head>
<body>
<app></app>
</body>
</html>
</app>
</body>
将templateUrl
更改为template
也有同样的问题。任何人都知道为什么app.html
不加载?为什么html会翻倍?控制台中没有错误。
编辑:
已将应用组件构造函数更新为 -
export class AppComponent {
constructor() {
alert('x');
}
}
我看到了警报。
所以问题是我没有从 Web 根目录引用路径。
@Component({
selector: 'app',
templateUrl: 'app.html'
})
应该是——
@Component({
selector: 'app',
templateUrl: 'client/app.html'
})
我希望抛出一些错误。另外,为什么它会将所有内容打印两次?
相关文章:
- 如何在react组件上应用css样式
- 如何在使用ui路由器时构造angular.js应用程序组件
- AngularJS组件和cms驱动应用程序的最佳实践
- 刷新子组件更改时的应用状态
- Windows 8 Metro UI HTML 应用中的自定义可重用 UI 组件
- 在应用程序中识别框架组件的覆盖的工具
- 通量:应用商店是否应通知组件有关更改的内容
- Web应用程序的组件 - Express.js,Angular.js和MVC混淆
- 角度 2 交叉应用程序(根组件)通信
- 将悬停时将 CSS 应用于多个组件
- 如何在 Vuejs 组件中应用过滤器
- 如何在应用程序的多个组件中维护一个 js 文件而不会出现任何错误
- 为什么我的应用组件呈现应用组件
- 如何将应用商店注入我的余烬组件
- 如何在应用程序模板中先加载 Ember 组件,然后再加载其他所有内容
- 为什么我的应用程序中的某些组件在IE7中工作,而在IE9中不起作用
- 应用样式“;游标:指针”;所有具有onClick功能的React组件
- 在react组件中应用moment()函数的位置
- 如何在Meteor Angular应用程序中安装bower组件
- 在Angular2中对嵌套组件应用css规则