学习angularjs时遇到 XX is not a function
- |
- 浏览:501
- |
- 更新:2015-04-23 15:51
-
出现这个问题是因为在 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">