简体   繁体   English

如何启动angular.dart应用

[英]how to start an angular.dart app

I am on angulardart 0.11.0 and this is my code for main.dart: 我正在使用angulardart 0.11.0,这是我的main.dart代码:

library my_app_main;

import 'package:angular/angular.dart';
import 'package:angular/application_factory.dart';

import 'package:my_app/src/something.dart';

class MyModule extends Module {
  MyModule() {
    bind(MyAppCtrl);
    bind(MyComp);
  }
}

main() {
  applicationFactory()
    .addModule(new MyModule())
    .run();
}

I get syntactic errors: 我收到语法错误:

  • angular.dart import is 'unused' angular.dart导入为“未使用”
  • 'Module' is an 'undefined class' “模块”是“未定义的类”

I have tried deleting and rebuilding the packages directory, pubspec file, etc. What is going on? 我尝试删除并重建软件包目录,pubspec文件等。这是怎么回事?

angular.dart import is 'unused' is just a warning, so you don't really need to worry about it. angular.dart import is 'unused'只是一个警告,因此您实际上不必担心它。

You're seeing 'Module' is an 'undefined class' because you're not importing the di library. 您看到'Module' is an 'undefined class''Module' is an 'undefined class'因为您没有导入di库。 Add import 'package:di/di.dart'; 添加import 'package:di/di.dart'; to your imports and it should run. 您的进口,它应该运行。

Turns out the error was caused by the angular files becoming corrupted in the pub cache. 原来,该错误是由角度文件在发布缓存中损坏引起的。 As was pointed out here ( https://groups.google.com/forum/#!topic/angular-dart/WiZuIwxTDb4 ) - thanks Günter! 正如此处所指出的( https://groups.google.com/forum/#!topic/angular-dart/WiZuIwxTDb4)-感谢Günter! - the solution is to repair the pub cache by doing 'pub cache repair' or at least 'pub cache add angular' -解决方案是通过执行“发布缓存修复”或至少执行“发布缓存添加角度”来修复发布缓存

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

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