简体   繁体   English

如何为 Angular 2.0 设置环境?

[英]How to setup the environment for Angular 2.0?

Taking my initial steps towards Angular 2.0.向 Angular 2.0 迈出我的第一步。

First thing is to set up the right environment for the development.首先是为开发设置合适的环境。

My index.html我的 index.html

<!DOCTYPE HTML>
<html>

<head>
  <title>Welcome to Angular 2.0</title>
  <!--css-->
  <link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
 </head>

 <body>
 <div class="container">
    <h1> Hello Angular 2 </h1>
      <my-app> Loading app component....<my-app>
</div>
<!--js-->
<!-- Polyfills for older browsers -->
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>

<script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.8"></script>
<script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js">   </script>

<script> window.autoBootstrap = true; </script>

<script src="https://cdn.rawgit.com/angular/angular.io/b3c65a9/public/docs/_examples/_boilerplate/systemjs.config.web.js"></script>
<script>
    System.import('app').catch(function (e) { console.log(e); });
  </script>
  <!--js-->
 </body>

 </html>

I have copied the content from https://angular.io/docs/ts/latest/guide/setup.html for the following files:-我已经从https://angular.io/docs/ts/latest/guide/setup.html复制了以下文件的内容:-

  • app.component.ts app.component.ts
  • app.module.ts app.module.ts
  • main.ts主文件

NPM is installed & running. NPM 已安装并正在运行。

节点

But in order to get the node_modules folders with the required dependencies for the app to run.但是为了获取具有运行应用程序所需的依赖项的node_modules文件夹。 What commands do I need to run.我需要运行什么命令。

What are the commands that I need to run to set up the Angular 2 environment?我需要运行哪些命令来设置 Angular 2 环境?

Please note I am new to NPM.请注意,我是 NPM 的新手。 Thanks.谢谢。

You have angular-cli wich is a good starter point.你有angular-cli,这是一个很好的起点。 It will set you everything up according to best practices.它将根据最佳实践为您设置一切。

Simple way to set up your first Angular 2 Application.设置您的第一个 Angular 2 应用程序的简单方法。

  1. Download the zip version here.在此处下载 zip 版本。 firstAngular2App第一个Angular2App

  2. Extract it to your destination folder.将其解压缩到您的目标文件夹。 Assume D:

  3. Open your command prompt(ensure that all required softwares are installed).打开命令提示符(确保安装了所有必需的软件)。

  4. Navigate it to the folder.将其导航到文件夹。 Use the command cd D:\\firstAngular2App使用命令cd D:\\firstAngular2App

  5. Executre npm install执行npm install

  6. Once it is done use npm start完成后使用npm start

This way you have your first Angular2 appliction up and running.这样您就可以启动并运行您的第一个 Angular2 应用程序。

npm install在根项目中(它将从package.json文件中提到的依赖项创建您的node_modules ,应该以这些文件作为开始)

If you are already using Visual Studio Code as an IDE, you may want to explore how they recommend setting up Angular .如果您已经在使用Visual Studio Code作为 IDE,您可能想了解他们建议如何设置 Angular I personally found their installation guide painless and feature-rich.我个人发现他们的安装指南轻松且功能丰富。 I have never walked through an official Angular installation before due to being drenched in jQuery projects.由于沉浸在 jQuery 项目中,我之前从未经历过官方的 Angular 安装。 This guide was simple enough to give me a good beginners understanding.本指南足够简单,让我对初学者有一个很好的理解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM