angular 学习过程中遇到的坑(整理中)

最近想学习下angular,然后该文章记录了我在学习中遇到的问题

1、参照书上的例子

hello.html

<!DOCTYPE html>  
<html ng-app="app">
<head>
  <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>  
    <script src="controllers.js"></script>  

</head>
<body>
<div ng-controller='HelloController'>
<p>{{greeting.text}},world</p>
</div>
</body>
</html>


controllers.js

function HelloController($scope){
$scope.greeting={text:'Hello'};
}

然后发现hello.html 报错了,没有出现预期的hello world


Error: [ng:areq] http://errors.AngularJS.org/1.4.8/ng/areq?p0=HelloCtrl&p1=not%20a%20function%2C%20got%20undefined

    at Error (native)
    at http://localhost:8080/web/rs/angular.min.js:1:503
    at qb (http://localhost:8080/web/rs/angular.min.js:1:8403)
    at Qa (http://localhost:8080/web/rs/angular.min.js:1:8490

原因:

上网查询刚开始以为是我angular版本的问题,后来发现不是版本问题

Angular出现这种错误的原因,是由于没有在页面中使用模块引入controller导致的,修改内容如下:

<!DOCTYPE html>  
<html ng-app="app">
<head>
  <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>  
    <script src="controllers.js"></script>  
<script type="text/javascript">
var app=angular.module("app",[]);
app.controller("HelloController",HelloController);
</script>  
</head>
<body>
<div ng-controller='HelloController'>
<p>{{greeting.text}},world</p>
</div>
</body>
</html>

2、因为需要nodeJs 快速编写一个简单的web服务器,在这里需要安装express,因为我是win7  64位 所以选择最新的msi安装,建议大家还是选择最新版本的,因为最新版本的已经内嵌了npm  这样不用自己再安装npm了,安装成功后接着在用npm install -g express的过程中出现了问题:

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\\nodejs\\\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-
cli.js" "install" "-g" "express"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! syscall connect


npm ERR! network connect ETIMEDOUT
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settin
gs.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'


npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\HSUPENG\npm-debug.log

因为是在公司的电脑上安装的 所以重新设置了代理和代理密码

比如公司代理IP为10.10.10.1  端口 8090  用户名:sss 密码:sss

只需作如下设置:npm config set proxy http://10.10.10.1:8090

                        npm config set https-proxy http://proxy-domain.com:8090

                            set http_proxy_user=sss

set http_proxy_password=sss


然后再安装 npm install -g express

                       



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值