简体   繁体   中英

how to start an angular.dart app

I am on angulardart 0.11.0 and this is my code for 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'
  • 'Module' is an 'undefined class'

I have tried deleting and rebuilding the packages directory, pubspec file, etc. What is going on?

angular.dart import is 'unused' is just a warning, so you don't really need to worry about it.

You're seeing 'Module' is an 'undefined class' because you're not importing the di library. Add 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! - the solution is to repair the pub cache by doing 'pub cache repair' or at least 'pub cache add angular'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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