angular - Meteor 不渲染 html 模板,只渲染路径

标签 angular meteor render angular2-template angular-meteor

我只是在 angular meteor 中开始新项目:

https://angular-meteor.com/tutorials/whatsapp2/meteor/setup

我的浏览器在下面显示了这个,这是放置html内容的文件的路径:

browser output

但是,在浏览器中它应该只是My App。 Meteor 不呈现 html 模板内容,而是呈现内容的路径。请给我建议。谢谢。

应用程序组件.ts:

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';
import template from './app.html';

@Component({
  selector: 'my-app',
  template
})
export class MyApp {
  constructor(platform: Platform) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      if (platform.is('cordova')) {
        StatusBar.styleDefault();
        Splashscreen.hide();
      }
    });
  }
}

应用程序模块.ts:

import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { BrowserModule } from '@angular/platform-browser';

import { MyApp } from './app.component';

@NgModule({
    declarations: [
      MyApp
    ],
    imports: [
      IonicModule.forRoot(MyApp),
      BrowserModule
    ],
    bootstrap: [IonicApp],
    entryComponents: [
      MyApp
    ],
    providers: [
      { provide: ErrorHandler, useClass: IonicErrorHandler }
    ]
  })
  export class AppModule {}

main.html:

<head>
  <title>Ionic2-MeteorCLI-WhatsApp</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="format-detection" content="telephone=no">
  <meta name="msapplication-tap-highlight" content="no">
  <meta name="theme-color" content="#4e8ef7">
</head>

<body>
  <ion-app></ion-app>
</body>

tsconfig.json:

{
    "compilerOptions": {
      "allowSyntheticDefaultImports": true,
      "baseUrl": ".",
      "declaration": false,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "lib": [
        "dom",
        "es2015"
      ],
      "module": "commonjs",
      "moduleResolution": "node",
      "sourceMap": true,
      "target": "es5",
      "skipLibCheck": true,
      "stripInternal": true,
      "noImplicitAny": false,
      "typeRoots": [
        "node_modules/@types/"
      ],
      "types": [
        "meteor-typings",
        "@types/underscore"
      ]
    },
    "include": [
      "client/**/*.ts",
      "server/**/*.ts",
      "imports/**/*.ts"
    ],
    "exclude": [
      "node_modules"
    ],
    "compileOnSave": false,
    "atom": {
      "rewriteTsconfig": false
    }
  }

编辑:

谢谢您的回答。编辑模板格式后 => 我收到新错误。我的页面现在是空的(应该有文本“我的应用程序”)并且我在控制台中有新的错误:

ERROR RangeError: Maximum call stack size exceeded
    at Object.resolveDep (modules.js?hash=3bc92748a65daa75c5e4de9e0dbe6210430d61f0:40111)
    at Injector_.get (modules.js?hash=3bc92748a65daa75c5e4de9e0dbe6210430d61f0:39683)
    at Object.resolveDep (modules.js?hash=3bc92748a65daa75c5e4de9e0dbe6210430d61f0:40179)
    at Injector_.get (modules.js?hash=3bc92748a65daa75c5e4de9e0dbe6210430d61f0:39683)
    at Object.resolveDep (modules.js?hash=3bc92748a65daa75c5e4de9e0dbe6210430d61f0:40179)
    at Injector_.get (modules.js?hash=3bc92748a65daa75c5e4de9e0dbe6210430d61f0:39683)
    at Object.resolveDep (modules.js?hash=3bc92748a65daa75c5e4de9e0dbe6210430d61f0:40179)
    at Injector_.get (modules.js?hash=3bc92748a65daa75c5e4de9e0dbe6210430d61f0:39683)
    at Object.resolveDep (modules.js?hash=3bc92748a65daa75c5e4de9e0dbe6210430d61f0:40179)
    at Injector_.get (modules.js?hash=3bc92748a65daa75c5e4de9e0dbe6210430d61f0:39683)

最佳答案

编译器包和 Angular 现在需要稍微不同的格式。删除导入行并更新组件

@组件({ 选择器:“我的应用程序”, templateUrl: ‘./app.html’ })

关于angular - Meteor 不渲染 html 模板,只渲染路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52051485/

相关文章:

Angular 5 显示基于数组选中的复选框

javascript - Angular2(v4.2.5) 点击事件在 *ngIF 中不起作用

templates - 如何使用 meteor 模板创建类似目录的结构?

javascript - Js 在 Rails 中渲染部分的正确位置

ruby-on-rails - Rails 渲染如何在 Controller 中工作?为什么它不使用布局?

javascript - 防止在 React 中显示原始 HTML

angular - angular-cli.json 中 node_modules 路径的 Intellisense?

angular - 如何防止 bsValueChange 在页面加载时触发 Angular ?

Nitrous 上的 meteor - meteor 'Assets' 的路径?

javascript - Meteor,如何修复 npm 包