簡體   English   中英

AngularDART組件

[英]AngularDART component

我在學習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>This is the angular: {{cmp.name}}</p>

<the-component></the-component>不起作用,不顯示任何內容!

謝謝

角度變換器從lib文件夾中選取組件。 如果將組件的文件(.dart,.html,.css)放在其他文件夾(即web )中,則需要在pubspec.yaml的transformers部分中指定它們。

例如,

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

希望這對你有用。

感謝所有試圖提供幫助的人,解決方案是將pubspec.yaml寫成:

dependencies:
angular: '>=0.12.0 <0.13.0'
transformers:
- angular: {html_files: "web/angularComponent.html"}

謝謝。

問題是你的pubspec.yaml沒有將angularComponent.html列為資產。

創建StaticClosureMap的Angular變換器沒有解析模板,從未看過cmp.name表達式,也從未生成過getter。

我們應該給你一個更好的錯誤信息。 如果您仍然完整地隔離了完整的項目,請在Github項目中提交一個錯誤,我們可以更好地體驗這種體驗。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM