typescript – 模块’“angular2 / angular2”’没有导出成员’F
我正在关注官方Angular2网站上的教程.
https://angular.io/docs/js/latest/guide/displaying-data.html 这是我的.ts文件: /// <reference path="typings/angular2/angular2.d.ts" /> import {Component,View,bootstrap,For} from 'angular2/angular2'; @Component({ selector: 'display' }) @View({ template: '<p>name: {{myName}}</p>' + '<p>Friends:</p>' + '<ul>'+ '<li *for="#name of names">'+ '{{name}}'+ '<li>'+ '<ul>',directives: [For] }) class DisplayComponent{ myName: string; names: Array<string>; constructotr(){ this.myName = "Alice"; this.names = ["Winston","Alex","Shannon","Irizu"]; } } bootstrap(DisplayComponent); 这是我的HTML: <html> <head> <script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script> <script src="https://jspm.io/system@0.16.js"></script> <script src="https://code.angularjs.org/2.0.0-alpha.23/angular2.dev.js"></script> </head> <body> <display></display> <script> System.import('show-properties'); </script> </body> </html> 我已经安装了angular2,Rx和es6-promise. 仍然存在错误.
更新 这是我更新的.ts代码: /// <reference path="typings/angular2/angular2.d.ts" /> import { ComponentAnnotation as Component,ViewAnnotation as View,NgFor } from 'angular2/angular2'; @Component({ selector: 'display' }) @View({ template: '<p>name: {{myName}}</p>' + '<p>Friends:</p>' + '<ul>'+ '<li *ng-for="#name of names">'+ '{{name}}'+ '<li>'+ '<ul>',directives: [NgFor] }) class DisplayComponent{ myName: string; names: Array<string>; constructotr(){ this.myName = "Alice"; this.names = ["Winston","Irizu"]; } } bootstrap(DisplayComponent); angular2.d.ts仍然是alpha 26. 现在没有错误消息,我可以看到 名称: 但是没有插入任何值.
您的问题是文档不同步.如果您最近按照文档进行安装,那么它将安装最新版本alpha26的类型,其中包含许多破坏的更改.该文档使用该版本代码的a23版本.你也可以
1)将您的打字更新为与v23匹配的旧版本,即find it here.复制内容并将其替换为./typings/angular2/angular2.d.ts. 2)将角度脚本升级到alpha 26并修复几件事. >现在是NgFor,如果现在是NgIf Demo – 23 Demo – 26 你也可以使用angular-class webpack starter的启动. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- angularjs – 如何在ui-router中继承解析数据
- 如何在异构环境下(两个服务器的Network Interface名称不一
- twitter-bootstrap – 将angular2表单指令应用于自定义输入
- WebService的简介, 原理, 使用
- macos – 无法在vim中安装FuzzyFinder
- 如何使用scala 2.10 trunk与sbt 0.11.0? (未解决的依赖项)
- vim – Nerd tree:enter不打开sub dirs
- [博客迁移]探索Windows Azure 监控和自动伸缩系列1 - 连接中
- 如何在使用Docker Compose时有效地重建项目?
- 如何将参数传递给控制器??中定义的方法,但是从Angularjs中的