【问题标题】:why the text is not display in angular?为什么文本不以角度显示?
【发布时间】:2016-04-19 07:25:26
【问题描述】:

我正在尝试以 Angular 2 显示组件文本。但它不是显示。您能告诉我哪里做错了吗? 这是我的代码

http://plnkr.co/edit/PrWxwf3wT5COVxRwIpqX?p=preview

<!DOCTYPE html>
<html>

  <head>
    <script src="https://code.angularjs.org/2.0.0-beta.0/angular2-polyfills.js"></script>
    <script src="https://code.angularjs.org/tools/system.js"></script>
    <script src="https://code.angularjs.org/tools/typescript.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.0/Rx.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.0/angular2.dev.js"></script>

    <script>
      System.config({
        transpiler: 'typescript', 
        typescriptOptions: { emitDecoratorMetadata: true }, 
        packages: {'gg': {defaultExtension: 'tp'}} 
      });
      System.import('boot')
            .then(null, console.error.bind(console));
    </script>
  </head>

  <body>
    <my-app>Loading...</my-app>
  </body>

</html>

【问题讨论】:

  • .tp 扩展名?这是用 .ts 打错还是真的是 .tp ?
  • 我拿 .tp ...不是误会
  • 哦,我不知道 .tp 扩展名 sry。
  • 您没有“app”或“gg”包,您正在寻找以根目录启动,但将默认扩展名“tp”添加到应用程序包中,移动您的 boot.tp如果您使用此示例,则将文件放在 gg 文件夹中,或者如果您像在 plunker 中那样操作,则将文件放在 app 文件夹中
  • 请提供 plunker ..或最好的方法来做到这一点

标签: angular angular2-routing angular2-template angular2-directives


【解决方案1】:

由于您没有文件夹(包),您可以明确指定您的扩展。

  System.import('boot.tp')
        .then(null, console.error.bind(console));

   import { AppComponent } from './script.tp'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-14
    • 2013-05-28
    • 2013-12-25
    • 1970-01-01
    相关资源
    最近更新 更多