Tag: angular2模板

如何使用Angular2路由

我试图写一个单页面的应用程序,但我不能让路由工作。 我尝试了很多教程,但是考虑到Angular2还处于testing阶段,他们似乎很快就过时了。 看来,只要我添加任何引用路由器指令或路由器configuration或路由器提供程序,应用程序停止工作,并在浏览器的控制台上打印以下错误: Error: Zone</ZoneDelegate</ZoneDelegate.prototype.invoke@http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:332:20 Zone</Zone</Zone.prototype.run@http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:227:25 scheduleResolveOrReject/<@http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:576:53 Zone</ZoneDelegate</ZoneDelegate.prototype.invokeTask@http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:365:24 Zone</Zone</Zone.prototype.runTask@http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:263:29 drainMicroTaskQueue@http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:482:26 ZoneTask/this.invoke@http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:434:22 Evaluating http://localhost:3000/angular2/router Error loading http://localhost:3000/app/main.js 现在我有以下文件,这是行不通的: index.html <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Rapid</title> <!– 1. Load libraries –> <!– IE required polyfills, in this exact order –> <link href="css/dashboard.css" rel="stylesheet"> <link href="css/bootstrap.min.css" rel="stylesheet"> <script src="node_modules/es6-shim/es6-shim.min.js"></script> <script src="node_modules/systemjs/dist/system-polyfills.js"></script> <script […]

Angular2与TypeScript:声明预期编译器错误@component后

我得到这种错误,尽pipe我从angular2 / core导入组件应该是它的来源是文件不是通过npm安装下载或我的节点需要升级 这是我的文件 import {bootstrap} from 'angular2/platform/browser'; import {Component, View} from 'angular2/core'; @Component({ })

如何检测Angular2中Date对象的变化?

使用setDate方法修改的date对象不会在模板中更新。 在模板中: <p>{{date | date:'mediumDate'}}</p> 在组件中: nextDay(){ this.date.setDate(this.date.getDate()+1); } 但是当我调用nextDay函数时,模板不会更新为新的值。 唯一能让变化检测工作的方法就是这样做: nextDay(){ var tomorrow = new Date(); tomorrow.setDate(this.date.getDate()+1); this.date = tomorrow; } 有没有更好的方法来完成这个相同的任务?