简体   繁体   English

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

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

I am new to Angular Dart.我是 Angular Dart 的新手。 I have installed Dart, and added dart plugin in VS code.我已经安装了 Dart,并在 VS 代码中添加了 dart 插件。 Then I created a bare bone project thru VS command pallette.然后我通过 VS 命令调色板创建了一个简单的项目。 But when I added this line in main.dart, I got build error.但是当我在 main.dart 中添加这一行时,我得到了构建错误。 It is as recommended by angular dart ie angular dart正如 angular dart 即angular ZBB14127678960FAE956D873950ZEA20所推荐的那样

Here is my main.dart file.这是我的 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);
}

Here is my app_component.dart这是我的 app_component.dart

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

In my index.html, I have this line在我的 index.html 中,我有这一行

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

But I am facing build error for the line但我面临生产线的构建错误

runApp(ng.AppComponentNgFactory);

I get this error:我收到此错误:

"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'.

The factory is not declared in the app_component.dart .工厂未在app_component.dart中声明。

It is generated by Angular compiler由 Angular 编译器生成

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

Which should have the right implementation.哪个应该有正确的实施。 See What does somecomponent.template.dart import in AngularDart point to?请参阅AngularDart 中的 somecomponent.template.dart 导入指向什么? for example.例如。

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

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