【发布时间】:2014-09-25 05:02:22
【问题描述】:
我在学习AngularDART组件的时候做了下面的简单代码,但是什么都没有显示,谁能帮我知道我犯了什么错误:
我的 html 主文件:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="bootstrap.css">
<link rel="stylesheet" href="main.css">
<title>AngularDART training</title>
<script type="application/dart" src="main.dart"></script>
<script src="packages/browser/dart.js"></script>
</head>
<body ng-app>
<h1 id='text_id'>Welcome</h1>
<the-component></the-component>
</body>
</html>
main.dart 文件是:
import 'package:angular/angular.dart';
import 'package:angular/application_factory.dart';
@Component(
selector: 'the-component',
templateUrl: 'angularComponent.html',
cssUrl: 'angularComponent.css',
publishAs: 'cmp')
class myComponent {var name = 'Component';}
main() {
var module = new Module()
..bind(myComponent);
applicationFactory().addModule(module).run();
}
angularComponent.html 文件是:
<p>This is the angular: {{cmp.name}}</p>
<the-component></the-component> 不工作,不显示任何内容!
谢谢
【问题讨论】:
-
启动应用程序时是否有任何错误/警告消息?
-
@GünterZöchbauer DART 编辑器出现以下错误。 ShadowRoot.resetStyleInheritance 和 ShadowRoot.applyAuthorStyles 现在在 dart:html 中已弃用。请从您的代码中删除它们。 'cmp' 没有吸气剂。 STACKTRACE: #0 StaticClosureMap.lookupGetter (package:angular/core/parser/parser_static.dart:15:25) #1 DynamicParserBackend.newAccessScope (package:angular/core/parser/dynamic_parser.dart:108:38)
-
@GünterZöchbauer .....经过多次试验和错误,考虑到我得到的错误消息是“'cmp'没有吸气剂。”我输入了如下虚拟变量,组件运行良好! !
标签: dart angular-dart