繁体   English   中英

Angular Dart 项目,为什么我看到错误 runApp(ng.AppComponentNgFactory)

[英]Angular Dart project, why am I seeing error runApp(ng.AppComponentNgFactory)

我是 Angular Dart 的新手。 我已经安装了 Dart,并在 VS 代码中添加了 dart 插件。 然后我通过 VS 命令调色板创建了一个简单的项目。 但是当我在 main.dart 中添加这一行时,我得到了构建错误。 正如 angular dart 即angular ZBB14127678960FAE956D873950ZEA20所推荐的那样

这是我的 main.dart 文件。

import 'dart:html';
import 'package:angular/angular.dart';
import 'package:angular_web_application/app_component.dart' as ng;
import 'package:http/browser_client.dart';

@GenerateInjector([
  ClassProvider(Client, useClass: BrowserClient),
])
void main() {
  runApp(ng.AppComponentNgFactory);
}

这是我的 app_component.dart

import 'package:angular/angular.dart';
@Component(
  selector: 'my-app',
  template: '<h1>Hello {{name}}</h1>',
)
class AppComponent {
  var name = 'Angular';
}

在我的 index.html 中,我有这一行

<my-app>Loading</my-app>

但我面临生产线的构建错误

runApp(ng.AppComponentNgFactory);

我收到此错误:

"message": "The name 'AppComponentNgFactory' is being referenced through the prefix 'ng', but it isn't defined in any of the libraries imported using that prefix.\nTry correcting the prefix or importing the library that defines 'AppComponentNgFactory'.

工厂未在app_component.dart中声明。

由 Angular 编译器生成

import 'package:angular_web_application/app_component.template.dart' as ng;

哪个应该有正确的实施。 请参阅AngularDart 中的 somecomponent.template.dart 导入指向什么? 例如。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM