学习angularjs时遇到 XX is not a function
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了学习angularjs时遇到 XX is not a function,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1355字,纯文字阅读大概需要2分钟。
内容图文
出现这个问题是因为在 angularJs 1.3 中 为了让 根节点上(rootScope)不再被挂上许多冗余的内容,所以禁止了直接在根上注册controller。
第一:以后不能直接以 function XXXcontroller (){ code......}这样的方式直接注册监听器了。以后必须
angular.module(‘phonecatApp‘, []).controller(‘PhoneListCtrl‘,function($scope) {}这样来将controller注册到对应的模型上。
第二: 在 ng-aap 中指定相对应的模型。
如 之前:
<html ng-app>(不指定则为根元素)
现在:
<html ng-app="phonecatApp">
<DOCTYPE html>
<html ng-app="HelloApp">
<head>
<title>test</title>
<script src="../../angular.js"></script>
</head>
<body ng-controller="CartController">
<h1>your Order</h1>
<div ng-repeat=‘item in items‘>
<span>{{item.title}}</span>
<input ng-model=‘item.quantity‘ >
<span> {{item.price}} </span>
<span>{{item.price*item.quantity}}</span>
<button ng-click="remove($index)">Remove</button>
</div>
<script type="text/javascript">
angular.module("HelloApp", []).controller("CartController", function($scope){
$scope.items=[
{ title: ‘paint pots‘, quantity: 8, price:3.95 },
{ title: ‘polka dots‘, quantity: 17, price: 12.95},
{ title: ‘Pebbles‘, quantity: 5, price: 6.95}
];
$scope.remove = function(index){
$scope.items.splice(index,1);
}
});
</script>
</body>
</html>
原文:http://www.cnblogs.com/facial/p/4524847.html
内容总结
以上是互联网集市为您收集整理的学习angularjs时遇到 XX is not a function全部内容,希望文章能够帮你解决学习angularjs时遇到 XX is not a function所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。