angular js 安装

 

 

使用:

  1. cmd 进入所建项目目录 执行   ng new website(website 为项目名称)

  2,进入1 所建项目目录中, 执行 ng serve  启动项目

  3,浏览器 输入  http://localhost:4200  就可以进入项目页面了

 

代码使用方法:

  1. 将数据输出到页面

export class AppComponent {
  username = "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"  //输出字符串
  login():void{                     //方法调用
    alert("iiiiiiiiiiiiiiiiiiiiiiiiiiiii")
  }
}
<button (click)="login()">{{username}}</button>

  

  2. 添加依赖,  例如要添加 bootstrap 

    1》 进入生成的 web 工程目录, 例如 D:\tools\idea_workspace\MovieRecommendSystem\website\website>

    2》执行 npm install bootstrap --save  就将会自动到 bootstrap 库中查找并加入

  3. 创建 module  dos进入 web 工程目录 例如:D:\tools\idea_workspace\MovieRecommendSystem\website\website>

    执行:ng g module AppRouting,  就会在  website/website/src/app/app-routing/app-routing.module.ts   目录下创建了一个  app-routing.module.ts  moudle

  3. 创建模块   dos进入 web 工程目录 例如:D:\tools\idea_workspace\MovieRecommendSystem\website\website>

    执行:ng g component home ,    就会在 website/website/src/app/     下创建出一个 home 模块

  4. 创建服务  dos进入 web 工程目录 例如:D:\tools\idea_workspace\MovieRecommendSystem\website\website>

    执行:ng g service service/login  就会在 website/website/src/app/     下创建出一个目录service, service 下回创建出 login 的服务

posted @ 2019-10-18 09:55  林**  阅读(357)  评论(0编辑  收藏  举报