Git Product home page Git Product logo

Comments (1)

llccing avatar llccing commented on July 24, 2024

“Angular Global API” 这个概念主要存在于 AngularJS(即 Angular 1.x)中。AngularJS 使用了一些全局函数和对象来提供核心功能,如模块化、依赖注入等。然而,在 Angular 2+(也称为 Angular,Angular 2及更高版本)中,框架的设计和结构发生了显著的变化,取消了大多数全局 API 的使用,转而使用更加模块化和面向对象的方式。

以下是 Angular 2+ 中的一些主要变化和设计理念:

  1. 模块化设计:Angular 2+ 使用 ES6 模块和 TypeScript,这意味着应用程序和库可以更清晰地组织和管理。Angular 应用程序由 NgModules 组成,每个模块都是一个功能块。

  2. 依赖注入:Angular 2+ 采用了更强大的依赖注入系统,依赖注入是在模块和组件级别进行配置和管理的,而不是通过全局 API。

  3. 无全局作用域:在 Angular 2+ 中,没有全局的 angular 对象。所有功能和服务都是通过模块导入和依赖注入来访问的,这提高了代码的可维护性和可测试性。

  4. 组件化:Angular 2+ 强调组件化开发,视图和逻辑通过组件来组织和管理,组件之间通过输入和输出进行通信。

以下是 AngularJS 和 Angular 2+ 的一些对比:

  • AngularJS:

    • 使用全局 angular 对象。
    • 使用 angular.module 定义模块。
    • 控制器和作用域是主要的构建块。
  • Angular 2+:

    • 没有全局 angular 对象。
    • 使用 @NgModule 装饰器定义模块。
    • 使用组件(@Component 装饰器)作为主要的构建块。

综上所述,Angular Global API 主要是指 AngularJS 中的全局函数和对象,在 Angular 2+ 中,框架设计更加现代化和模块化,取消了大多数全局 API。

from fe-interview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.