Angular(一) Creating my first web page using Angular

这篇具有很好参考价值的文章主要介绍了Angular(一) Creating my first web page using Angular。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Ⅰ. Basic knowledge about angular

        Angular is a popular open-source framework for building web applications. Here are some basic concepts and knowledge about Angular:

1. TypeScript: Angular is built with TypeScript, a superset of JavaScript that adds static typing and other features to enhance development.

2. Components: Angular applications are built using components, which are self-contained units that encapsulate the HTML, CSS, and logic for a specific part of the user interface.

3. Templates: Angular uses HTML templates to define the structure and layout of the user interface. Templates can include data bindings, directives, and other Angular-specific syntax.

4. Directives: Angular provides a set of built-in directives that allow you to extend HTML with additional functionality. Directives can be used to manipulate the DOM, add or remove elements, handle events, and more.

5. Services: Services in Angular are used to share data and functionality across multiple components. They are typically used for tasks such as making HTTP requests, handling authentication, or managing application state.

6. Dependency Injection: Angular uses dependency injection to manage the creation and sharing of objects. This allows you to easily inject dependencies into components, services, and other parts of your application.

7. Routing: Angular provides a powerful routing system that allows you to navigate between different views or pages within your application. You can define routes, associate them with components, and handle navigation events.

8. Modules: Angular applications are organized into modules, which are containers for related components, services, and other features. Modules help to keep your codebase modular and maintainable.

9. Reactive Forms: Angular provides a reactive forms module that allows you to build complex, data-driven forms with validation and other advanced features.

10. Testing: Angular has built-in support for testing, with tools like Karma and Jasmine. You can write unit tests for your components, services, and other parts of your application to ensure their correctness.

These are just some of the basic concepts in Angular. As you delve deeper into Angular development, you'll encounter more advanced topics and features.

Ⅱ. Deploy a local application

1. Install Node.js: Angular services  Node.js and npm (Node package manager) to be installed on your machine, you can download and install Node.js from the offical website:https://nodejs.org

Angular(一) Creating my first web page using Angular,vue-react-angular-web,angular,angular.js

we can run this command to configure the  domestic mirror to facilitate the speed of downloading dependencies

npm config set registry https://registry.npm.taobao.org

2. Install Angular CLI(command line interface ) is a powerful tool that helps in creating and managing project, Open you command terminal and command prompt and run the following  command to install angular CLI globally:  

npm install -g @angular/cli

Angular(一) Creating my first web page using Angular,vue-react-angular-web,angular,angular.js

Angular(一) Creating my first web page using Angular,vue-react-angular-web,angular,angular.jsAngular(一) Creating my first web page using Angular,vue-react-angular-web,angular,angular.js

 3. Creating a angular project, Once angluar cli installed , you can create your first  angular project by running following command, but firstly, cd a target directory

ng new my-first-app

Angular(一) Creating my first web page using Angular,vue-react-angular-web,angular,angular.js

4.  this command will help creating a new directory named "my-first-app" with the basic structure of angular project.

Angular(一) Creating my first web page using Angular,vue-react-angular-web,angular,angular.js

if you want add another feature in your app, you can use the above command 'ng generate component  componentName'.

 ng generate component Topbar

Angular(一) Creating my first web page using Angular,vue-react-angular-web,angular,angular.js  

It will automatically produce the Topbar directory in "src/app" directory.

The last step is to serve our first application by running following command:

 ng serve

Angular(一) Creating my first web page using Angular,vue-react-angular-web,angular,angular.js

 5. This will start a local deployment server  and serve our application at "http://localhost:4200", you can see a welcome page  like this below:

Angular(一) Creating my first web page using Angular,vue-react-angular-web,angular,angular.js

Ⅲ. Project Structure

1. Package.json

        Every project has a place to config all dependencies for better management , including angular,  we can see the package.json file in left menu bar under the root folder, there are some key properties to refer to:

  1.  Scripts:  map npm command to ng command.
  2.  dependencies:  all dependencies for production env.
  3.  devDependencies: are those packages in the package.json file that you need only for project development  purpose,example, babel,webpack. 

Angular(一) Creating my first web page using Angular,vue-react-angular-web,angular,angular.js文章来源地址https://www.toymoban.com/news/detail-719869.html

到了这里,关于Angular(一) Creating my first web page using Angular的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Creating WebAR Applications Using JavaScript and Node.j

    作者:禅与计算机程序设计艺术 Augmented Reality(AR)是一种利用现实世界中的图像、声音、或其他媒体来增强现实的技术。它能够将虚拟对象投射到真实世界中,使得用户可以参与其中并进行交互。Web AR应用程序(Web AR App)就是在网页浏览器上运行的AR应用。本文将介绍如何通过

    2024年02月06日
    浏览(51)
  • error: ‘theachar‘ undeclared (first use in this function); did you mean ‘theacher‘?

    在c语言编程当中遇到error: ‘theachar’ undeclared (first use in this function); did you mean ‘theacher’?问题 看如下代码: 这里可以看到,上面定义了一个theacher变量,下面却用了一个teacher未定义的一个变量,这明显是错误的,但大型程序当中密密麻麻的很容易遗漏此问题,所已为了演示

    2024年02月16日
    浏览(41)
  • 【WEEK2】 【DAY1】The First MVC Program Using Annotations【English Version】

    2024.3.4 Monday Following the section 【WEEK1】 【DAY5】First MVC Program: Configuration File【English Version】 Mainly includes core libraries of Spring framework, Spring MVC, servlet, JSTL, etc. (Already included in the parent dependency: only check the Dependencies in the Maven sidebar) Add web support (see W1D2 1.3 Establish a module named springmv

    2024年03月14日
    浏览(69)
  • Angular 异常 NG0904: unsafe value used in a resource URL context

    问题描述 主要是用变量对iframe页面的参数进行赋值时报错,直接使用字符串不会报错、 故障原因 -因为在iframe中执行angular不信任的操作,需要使用angular提供的DomSanitizer 解决办法 使用Angular提供的DomSanitizer 创建一个Pipe 声明Pipe 使用pipe 参考链接 1.Unsafe value used in a resource URL

    2024年02月13日
    浏览(38)
  • Component is not found in path “components/xxx/xxx“ (using by “pages/xxx/xxx“) 问题记录

    相信做过小程序的都遇到过Component is not found in path “components/xxx/xxx“ (using by “pages/xxx/xxx“) 这个问题,一般情况的是引用路径有问题,检查代码路径改对就好了,又或者是 分包 影响的 先说一下我得使用场景,不一定适用于所有人,只是记录一下我遇到的 1.小程序是分包的

    2024年02月02日
    浏览(52)
  • Web - Angular 的 AJAX 与 REST

            AJAX 是用于描述网页与网络服务器互动的一系列技术的术语。它不是一项新技术,而是对长时间以来已存在技术的应用。随着主要网站(例如谷歌)展示其优势,它作为一种开发技术变得流行。AJAX 这个术语被创造出来,用以描述异步 JavaScript 和 XML 应用程序。在本

    2024年01月17日
    浏览(35)
  • 深入探索Angular:构建现代化的Web应用

    Angular是一种流行的前端开发框架,被广泛用于构建现代化的Web应用。作为一名技术专家,我们需要深入了解Angular的核心原则和设计思想,并学会如何应用它来构建出色的Web应用。本篇博客将详细介绍Angular,包括其基本概念、关键组件以及实际案例。 Angular是一个基于TypeScr

    2024年02月12日
    浏览(73)
  • 探索Angular:现代Web应用开发的强大框架

    项目地址:https://gitcode.com/htmlk/angular Angular 是一个由Google维护的开源JavaScript框架,用于构建高性能、可测试且模块化的单页应用程序(SPA)。这篇技术文章将深入介绍Angular的核心特性,其工作原理,以及它如何帮助开发者构建复杂的Web应用。 Angular是一个完整的MVC(模型-视图

    2024年04月23日
    浏览(45)
  • Angular框架:基于TypeScript的Web应用开发框架

    Angular 框架是一款基于 TypeScript 的 Web 应用开发框架,它的诞生改变了 Web 开发的面貌,为开发者提供了更高效、可维护性、可扩展性的开发体验。 Angular 框架不仅在前端框架中占有重要地位,也被众多企业和开发者广泛应用于生产环境中。 首先,让我们来了解一下 TypeScript

    2024年02月13日
    浏览(50)
  • 前端面试:【Angular】打造强大Web应用的全栈框架

    嗨,亲爱的Angular探险家!在前端开发的旅程中,有一个全栈框架,那就是 Angular 。Angular提供了模块化、组件化、依赖注入、路由和RxJS等特性,助力你构建强大、可扩展的Web应用。 1. 什么是Angular? Angular是一个由Google开发的JavaScript框架,用于构建现代Web应用。它是一个全栈

    2024年02月11日
    浏览(40)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包