AngularDART组件

前端之家收集整理的这篇文章主要介绍了AngularDART组件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在学习AngularDART组件时制作了以下简单的代码,但没有显示任何内容,任何人都可以帮助我知道我犯了什么错误

我的html主文件

<!DOCTYPE html>
    <html>
    <head>
        <link rel="stylesheet" href="bootstrap.css">
        <link rel="stylesheet" href="main.css">
        <title>AngularDART training</title>
        <script type="application/dart" src="main.dart"></script>
        <script src="packages/browser/dart.js"></script>
    </head>
    <body ng-app>
        <h1 id='text_id'>Welcome</h1>
        <the-component></the-component>
    </body>
    </html>

main.dart文件是:

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

      @Component(
          selector: 'the-component',templateUrl: 'angularComponent.html',cssUrl: 'angularComponent.css',publishAs: 'cmp')
      class myComponent {var name = 'Component';}

      main() {
        var module = new Module()
                         ..bind(myComponent);

        applicationFactory().addModule(module).run();
      }

angularComponent.html文件是:
       < p>这是角度:{{cmp.name}}< / p>

< the-component>< / the-component>不工作,没有显示任何东西!

谢谢

解决方法

角度变换器从lib文件夹中选取组件.如果将组件的文件(.dart,.html,.css)放在其他文件夹(即Web)中,则需要在pubspec.yaml的transformers部分中指定它们.

例如,

transformers
   - angular:
     -html_files:
        - absolute/path/to/your/html

希望这对你有用.

猜你在找的Angularjs相关文章