当前位置: 首页 > news >正文

Angularjs学习---官方phonecat实例学习angularjs step0 step1

接下来一系列的文章都是学习https://docs.angularjs.org/tutorial的笔记,主要学习的angular-phonecat项目的实现,来介绍angularjs的使用.

1.下载angular-phonecat

使用git clone phonecat:

git clone --depth=14 https://github.com/angular/angular-phonecat.git

可以把--depth=14去掉,这里是拉最新的14个commit.

The --depth=14 option just tells Git to pull down only the last 14 commits. This makes the download much smaller and faster.

2.安装所需工具

Bower - client-side code package manager
Http-Server - simple local static web server
Karma - unit test runner
Protractor - end 2 end test runner

nodejs,npm,karma的安装可以参考前面的文章:Angularjs学习---ubuntu12.04中karma安装配置中常见的问题总结

1).ubuntu中安装bower命令为:

sudo npm install -g bower

2).安装驱动:

npm run update-webdriver

这里好像安装的是selenium驱动.

3).启动项目:npm start

 

amosli@amosli-pc:~/develop/angular-phonecat$ npm start

> angular-phonecat@0.0.0 prestart /home/amosli/develop/angular-phonecat
> npm install


> angular-phonecat@0.0.0 postinstall /home/amosli/develop/angular-phonecat
> bower install


> angular-phonecat@0.0.0 start /home/amosli/develop/angular-phonecat
> http-server -p 8000

Starting up http-server, serving ./ on port: 8000
Hit CTRL-C to stop the server

 

 4).端到端的测试:

npm run protractor 
  • open up a Chrome browser and connect it to the application 
  • execute all the End to End tests in this browser
  • report the results of these tests in the terminal/command line window
  • close down the browser and exit

自动化测试步骤是打开chrome浏览器,连接到应用程序这里是angular-phonecat---->执行所有的端到端的测试---->在命令行中报告测试结果---->关闭浏览器并退出.

3.phonecat项目教程概述

教程分为13步,每一步可以切换到相应的分支上直接运行其步骤,比如要学习第0步的内容,那么执行如下命令:

amosli@amosli-pc:~/develop/angular-phonecat$ git checkout step-0
Previous HEAD position was b1e657a... step-4 phone ordering
HEAD is now at c5495a2... step-0 bootstrap angular app

同样,可以看到的切换的步骤有step-0到12.

4.phonecat项目step-0

1).切换到第0步,启动项目:

amosli@amosli-pc:~/develop/angular-phonecat$ git checkout step-0
Previous HEAD position was b1e657a... step-4 phone ordering
HEAD is now at c5495a2... step-0 bootstrap angular app
amosli@amosli-pc:~/develop/angular-phonecat$ npm start

2).在浏览器输入http://localhost:8000/app/index.html

效果:

index.html的源码

<!doctype html>
<html lang="en" ng-app>
<head>
  <meta charset="utf-8">
  <title>My HTML File</title>
  <link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css">
  <link rel="stylesheet" href="css/app.css">
  <script src="../bower_components/angular/angular.js"></script>
</head>
<body>

  <p>Nothing here {{'yet' + '!'}}</p>

</body>
</html>

其数据渲染顺序:

  1. injector that will be used for dependency injection is created.

  2. The injector will then create the root scope that will become the context for the model of our application.

  3. Angular will then "compile" the DOM starting at the ngApp root element, processing any directives and bindings found along the way.

 

5.phonecat项目step-1

请编辑app/index.html文件,将下面的代码添加到index.html文件中,然后运行该应用查看效果。

<ul>
    <li>
        <span>Nexus S</span>
        <p>
        Fast just got faster with Nexus S.
        </p>
    </li>
    <li>
        <span>Motorola XOOM™ with Wi-Fi</span>
        <p>
        The Next, Next Generation tablet.
        </p>
    li>
</ul>

效果:

 

 

 

 

 

 

 

 

 

 

 

相关文章:

  • yum KVM
  • NLP
  • NIO入门系列之第二章:通道和缓冲区
  • 我们为何要选择响应式设计?
  • Redhat 企业虚拟化应用案例合集
  • AWK命令如何输出单引号
  • [Android Pro] android 混淆文件project.properties和proguard-project.txt
  • 9. JDK、JRE 的下载安装配置
  • String类的intern()方法
  • django 快速搭建blog
  • 常用搜索引擎指令
  • 远程连接
  • Oracle 11g AWR 系列五:如何生成 AWR 报告?
  • ScaleType
  • 每次重启之后不丢失挂载点
  • 【跃迁之路】【699天】程序员高效学习方法论探索系列(实验阶段456-2019.1.19)...
  • AzureCon上微软宣布了哪些容器相关的重磅消息
  • ES6核心特性
  • jquery ajax学习笔记
  • JS 面试题总结
  • JS函数式编程 数组部分风格 ES6版
  • Just for fun——迅速写完快速排序
  • niucms就是以城市为分割单位,在上面 小区/乡村/同城论坛+58+团购
  • Spring Cloud中负载均衡器概览
  • ucore操作系统实验笔记 - 重新理解中断
  • zookeeper系列(七)实战分布式命名服务
  • 更好理解的面向对象的Javascript 1 —— 动态类型和多态
  • 基于Android乐音识别(2)
  • 来,膜拜下android roadmap,强大的执行力
  • 每个JavaScript开发人员应阅读的书【1】 - JavaScript: The Good Parts
  • 爬虫模拟登陆 SegmentFault
  • 浅谈web中前端模板引擎的使用
  • 如何抓住下一波零售风口?看RPA玩转零售自动化
  • 删除表内多余的重复数据
  • 深度学习入门:10门免费线上课程推荐
  • 实现简单的正则表达式引擎
  • 使用docker-compose进行多节点部署
  • 数组大概知多少
  • 我这样减少了26.5M Java内存!
  • 想晋级高级工程师只知道表面是不够的!Git内部原理介绍
  • 一、python与pycharm的安装
  • 关于Kubernetes Dashboard漏洞CVE-2018-18264的修复公告
  • #调用传感器数据_Flink使用函数之监控传感器温度上升提醒
  • #我与Java虚拟机的故事#连载11: JVM学习之路
  • ()、[]、{}、(())、[[]]等各种括号的使用
  • (4)Elastix图像配准:3D图像
  • (差分)胡桃爱原石
  • (二)什么是Vite——Vite 和 Webpack 区别(冷启动)
  • (附源码)计算机毕业设计SSM教师教学质量评价系统
  • (循环依赖问题)学习spring的第九天
  • (转)linux自定义开机启动服务和chkconfig使用方法
  • ***检测工具之RKHunter AIDE
  • .NET / MSBuild 扩展编译时什么时候用 BeforeTargets / AfterTargets 什么时候用 DependsOnTargets?
  • .net framework profiles /.net framework 配置
  • .Net Redis的秒杀Dome和异步执行