angular.min.js:118 Error: [ng:areq] http://errors.angularjs.org/1.5.8/ng/areq?

1、錯誤描述

[html] view plain copy
 print?在CODE上查看代碼片派生到我的代碼片
  1. angular.min.js:118 Error: [ng:areq] http://errors.angularjs.org/1.5.8/ng/areq?p0=username&p1=not%20a%20function%2C%20got%20undefined  
  2.     at Error (native)  
  3.     at http://127.0.0.1:8020/AngularJS/js/angular.min.js:6:412  
  4.     at sb (http://127.0.0.1:8020/AngularJS/js/angular.min.js:23:18)  
  5.     at Pa (http://127.0.0.1:8020/AngularJS/js/angular.min.js:23:105)  
  6.     at http://127.0.0.1:8020/AngularJS/js/angular.min.js:89:310  
  7.     at ag (http://127.0.0.1:8020/AngularJS/js/angular.min.js:72:419)  
  8.     at p (http://127.0.0.1:8020/AngularJS/js/angular.min.js:64:262)  
  9.     at g (http://127.0.0.1:8020/AngularJS/js/angular.min.js:58:481)  
  10.     at g (http://127.0.0.1:8020/AngularJS/js/angular.min.js:58:498)  
  11.     at g (http://127.0.0.1:8020/AngularJS/js/angular.min.js:58:498)  


2、錯誤原因

[html] view plain copy
 print?在CODE上查看代碼片派生到我的代碼片
  1. <!DOCTYPE html>  
  2. <html ng-app>  
  3.     <head>  
  4.         <meta charset="UTF-8">  
  5.         <title></title>  
  6.         <script type="text/javascript" src="../js/angular.min.js" ></script>  
  7.     </head>  
  8.     <body>  
  9.         <div ng-controller="username">  
  10.             <input type="text" id="inp" ng-model="user.name">  
  11.             <div>{{user.name}}</div>  
  12.         </div>  
  13.         <script>  
  14.             function username($scope)  
  15.             {  
  16.                 $scope.user = {name:"傑西卡"};  
  17.             }  
  18.         </script>  
  19.     </body>  
  20. </html>  


3、解決辦法

[html] view plain copy
 print?在CODE上查看代碼片派生到我的代碼片
  1. <!DOCTYPE html>  
  2. <html ng-app="userApp">  
  3.     <head>  
  4.         <meta charset="UTF-8">  
  5.         <title></title>  
  6.         <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>  
  7.         <script>  
  8.             var app = angular.module("userApp",[]);  
  9.             app.controller("username",function($scope){  
  10.                 $scope.user = {name:"傑西卡"}  
  11.             });  
  12.         </script>  
  13.     </head>  
  14.     <body>  
  15.         <div ng-controller="username">    
  16.             <input type="text" id="inp" ng-model="user.name">    
  17.             <div>{{user.name}}</div>    
  18.         </div>    
  19.     </body>  
  20. </html>  
發佈了20 篇原創文章 · 獲贊 124 · 訪問量 92萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章