Файл .template.dart не создается

Я пытаюсь заставить класс Routes работать. Когда я пытаюсь импортировать

import 'package:mango/src/component/pages/dashboard_component.template.dart' as dashboard_template;

Я получаю эту ошибку:

[SEVERE] build_web_compilers|entrypoint on web/main.dart:
Unable to find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a dev_dependency
needs to move to a real dependency), or a build failure (if importing a
generated file).

Please check the following imports:

`import 'src/component/pages/dashboard_component.template.dart' as _ref3;` from mango|lib/app_component.template.dart at 19:1
`import 'package:mango/lib/src/component/pages/dashboard_component.template.dart' as dashboard_template;` from mango|lib/src/routes.template.dart at 9:1
`import 'package:mango/lib/src/component/pages/dashboard_component.template.dart' as dashboard_template;` from mango|lib/src/routes.dart at 5:1

И, глядя на структуру каталогов сборки, я заметил, что Dashboard_component.template.dart не был создан, в то время как все остальные созданы.

lib/src/routes.dart

import 'package:angular_router/angular_router.dart';
import 'package:mango/src/component/pages/dashboard_component.template.dart' as dashboard_template;
import 'route_paths.dart';
export 'route_paths.dart';

class Routes {
    static final dashboard = RouteDefinition(
        routePath: RoutePaths.dashboard,
        component: dashboard_template.DashboardComponentNgFactory,
        useAsDefault: true,
    );

    static final all = <RouteDefinition>[
        dashboard,
    ];
}

lib/src/component/pages/dashboard_component.dart

import 'package:angular/angular.dart';
import '../customers/customers_component.dart';
import '../customers/new_customer_component.dart';
import '../../data_service.dart';

@Component(
  selector: 'dashboard',
  templateUrl: 'dashboard_component.html',
  providers: [
    CustomersComponent,
    NewCustomerComponent,
  ],
)
class DashboardComponent {
  final DataService _dataService;

  DashboardComponent(this._dataService);
}

lib/app_component.dart

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

import 'src/component/header/header_component.dart';
import 'src/component/pages/dashboard_component.dart';
import 'src/model/customer.dart';
import 'src/data_service.dart';
import 'src/routes.dart';

@Component(
  selector: 'app',
  templateUrl: "app_component.html",
  styleUrls: ['app_component.css'],
  directives: [
    coreDirectives,
    routerDirectives,
    HeaderComponent,
    DashboardComponent,
  ],
  providers: [ClassProvider(DataService)],
  exports: [RoutePaths, Routes],
)
class AppComponent implements OnInit {
  final DataService dataService;

  List<Customer> get customers => dataService.customers;

  AppComponent(this.dataService);

  @override
  ngOnInit() {
    dataService.init();
  }
}

Я искал другие темы, но я не мог найти ничего полезного.


person double11one    schedule 23.09.2018    source источник
comment
кажется, у вас есть ошибка в dashboard_component.html, вы можете опубликовать ее?   -  person Hadrien Lejard    schedule 24.09.2018


Ответы (1)


Я думаю, что в вашем .html есть ошибки, поэтому шаблон не создается в .dart_tools/build/generated

Удалите папку .dart_tools/build. Затем в командной строке выполните -

 pub run build_runner build --delete-conflicting-outputs

Это должно показать некоторые ошибки. Если нет, вам нужно вручную проверить синтаксис в html-файле.

Также проверьте, все ли правильные директивы и поставщики перечислены в файле .dart.

person marcg    schedule 23.09.2018
comment
Спасибо, запуск этой команды показал мне лучшее описание ошибки. Шаблон не был создан из-за отсутствия директивы в DashboardComponent. - person double11one; 29.09.2018