Module.DEFAULT_REFLECTOR 未初始化 [英] Module.DEFAULT_REFLECTOR not initialized

查看:22
本文介绍了Module.DEFAULT_REFLECTOR 未初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置一个 AngularDart/PolymerDart 项目,但一直遇到以下错误:

出现异常:Module.DEFAULT_REFLECTOR 未针对依赖项注入进行初始化.http://goo.gl/XFXx9G

现在我已经阅读了错误末尾给出的 url 后面的页面并做了一些 Stackoverflowing,但我遇到的唯一解决方案是在 pubspect.yaml 中添加 -angular 作为转换器.所以我做到了.但我仍然收到同样的错误,我的项目无法启动.

我的 pubspec.yaml:

名称:应用程序描述:应用依赖:角度:'> = 1.0.0 <2.0.0'angular_node_bind: 任何核心元素:'>=0.3.2 <0.5.0'纸元素:'>=0.5.0 <0.6.0'聚合物:'>=0.14.0<0.16.0'web_components: '>=0.9.0 <0.10.0'依赖覆盖:参数:'>=0.10.0 <0.12.0'code_transformers: '>=0.1.4+2 <0.3.0'html5lib: '>=0.10.0 <0.13.0'观察:'>=0.11.0 <0.13.0'变压器:- 有角度的- 聚合物:入口点:- 客户端/网络/index.html

index.html:

<头><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>应用</title><!-- 包括支持 Dart 的 web_components polyfill.--><script src="../packages/web_components/platform.js"></script><!-- 进口--><link rel="import" href="../packages/polymer/polymer.html"><link rel="import" href="components/component.html"><身体><!--不要将 ng-app 放在 html 或 body 上.聚合物构建内联自定义元素定义,如果代码内联在 ng-app 内--><div ng-app><部分><p>角度</p><p><input type="text" ng-model="cool">角度绑定:{{cool}}</p></节><部分><p>聚合物</p><my-element message="[[cool ]]"></my-element></节>

<!-- 初始化--><script type="application/dart" src='dart/init.dart'></script><script src="../packages/browser/dart.js"></script></html>

init.dart:

import 'package:polymer/polymer.dart';导入'包:角度/application_factory.dart';导入 'package:angular_node_bind/angular_node_bind.dart' 显示 NodeBindModule;无效主(){initPolymer().跑(() {应用工厂().addModule(new NodeBindModule()).跑();});}

解决方案

看来web"文件夹必须与您的 pubspec.yaml 位于同一文件夹中.我将 web 文件夹放在文件夹client"中,这导致了问题.再次将 web 文件夹放在项目根文件夹中解决了这个问题.

I'm setting up an AngularDart/PolymerDart project, but I keep running against the following error:

Breaking on exception: Module.DEFAULT_REFLECTOR not initialized for dependency injection. http://goo.gl/XFXx9G

Now I've read the page behind the url given at the end of the error and did some Stackoverflowing, but the only sollution I came across was adding -angular as a transformer in the pubspect.yaml. And so I did. But still I keep getting the same error and my project won't start.

My pubspec.yaml:

name: application
description: application
dependencies:
  angular: '>=1.0.0 <2.0.0'
  angular_node_bind: any
  core_elements: '>=0.3.2 <0.5.0'
  paper_elements: '>=0.5.0 <0.6.0'
  polymer: '>=0.14.0 <0.16.0'
  web_components: '>=0.9.0 <0.10.0'
dependency_overrides:
  args: '>=0.10.0 <0.12.0'
  code_transformers: '>=0.1.4+2 <0.3.0'
  html5lib: '>=0.10.0 <0.13.0'
  observe: '>=0.11.0 <0.13.0'
transformers:
- angular
- polymer:
    entry_points:
    - client/web/index.html

index.html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Application</title>

    <!-- include the web_components polyfills with support for Dart. -->
    <script src="../packages/web_components/platform.js"></script>

    <!-- imports -->
    <link rel="import" href="../packages/polymer/polymer.html">
    <link rel="import" href="components/component.html">

  </head>
  <body>

    <!--
      don't put ng-app on html or body. the polymer build inlines
      custom elements definitions, which can trigger bugs if the code
      inlined is inside of ng-app
     -->
    <div ng-app>      
      <section>
        <p>Angular</p>
        <p>
          <input type="text" ng-model="cool"> Angular binding: {{cool}}
        </p>
      </section>

      <section>
        <p>Polymer</p>
        <my-element message="[[ cool ]]"></my-element>
      </section>
    </div>

    <!-- initialize -->
    <script type="application/dart" src='dart/init.dart'></script>
    <script src="../packages/browser/dart.js"></script>

  </body>
</html>

init.dart:

import 'package:polymer/polymer.dart';
import 'package:angular/application_factory.dart';
import 'package:angular_node_bind/angular_node_bind.dart' show NodeBindModule;

void main() {
  initPolymer()
    .run(() {
     applicationFactory()
       .addModule(new NodeBindModule())
       .run();
    });

}

解决方案

It appears that the "web" folder MUST be in the same folder as your pubspec.yaml. I placed the web folder inside a folder "client", which caused the problem. Putting the web folder in the project root folder again fixed the issue.

这篇关于Module.DEFAULT_REFLECTOR 未初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆