【问题标题】:Where is the entry point specified in angular application角度应用程序中指定的入口点在哪里
【发布时间】:2019-07-18 14:50:39
【问题描述】:

我是 Angular 新手,使用 angular-cli 安装了示例 Angular 应用程序。这有 package.json 文件,该文件通常必须具有该应用程序的入口点。但我没有发现在这个预定义的 pakage.json 文件中定义。 Angular 应用程序的入口点在哪里指定,为什么没有按预期在 package.json 文件中指定。

【问题讨论】:

  • 因为它不是您运行的节点脚本。入口点可以在main.ts 中找到,在platformBrowserDynamic().bootstrapModule(AppModule) 行下

标签: angular angular-cli package.json


【解决方案1】:

Angular 不提供类似于node.js 的入口点,而是提供一个已编译的应用程序(一堆 .js 文件、.css 文件、资产和一个 index.html 文件)。打开index.html文件即可运行应用程序。

将编译应用程序的哪些部分由您的 main.ts 文件决定,主要是行

platformBrowserDynamic().bootstrapModule(AppModule)

将 AppModule 定义为应用程序的“入口点”。

它是您引导启动应用程序的“根”模块

更多详情请查看this documentation

【讨论】:

    【解决方案2】:

    Angular 和 node.js 完全不同。 Angular 有自己的方式管理项目结构

    加载 Angular 项目时...它会引导 main.ts 中定义的模块...这是您的 AppModule。

    platformBrowserDynamic().bootstrapModule(AppModule);
    

    另外,请注意您正在使用 TypeScript 文件。这些文件被转译为 JavaScript,然后由 Angular 编译器编译。

    【讨论】:

      【解决方案3】:

      main.ts >> app.Module.ts >> app.component.ts >> index.html >> app.component.html

      是角度应用程序的起点 可以参考here

      【讨论】:

        猜你喜欢
        • 2020-05-12
        • 1970-01-01
        • 1970-01-01
        • 2019-03-21
        • 1970-01-01
        • 2012-12-24
        • 1970-01-01
        • 2013-04-18
        • 2020-02-26
        相关资源
        最近更新 更多