2017-05-26 92 views
-1

當我使用ng-controller=""時,它不起作用。角度:ng控制器不工作?

我在我的Web瀏覽器控制檯中出現此錯誤。有誰能幫助解決這個問題嗎?

[1]: https://

這是我的HTML代碼,我使用的測試。當我刪除ng-controller =「」時,angular正在工作,但我無法使用ng-controller =「」作爲我的代碼。

<!DOCTYPE> 
 
<html ng-app> 
 
\t <head> 
 
\t \t <title>APP</title> 
 

 
\t \t <!-- Latest compiled and minified CSS --> 
 
\t \t <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
 

 
\t \t <!-- Optional theme --> 
 
\t \t <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> 
 
    <script src="controllers/controller.js"> 
 
\t </script> 
 

 
\t \t <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"> 
 
\t \t </script> 
 

 
\t </head> 
 
\t <body> 
 
\t \t <div class="container" ng-controller="AppCtrl"> 
 

 
\t \t <h1>Users</h1> 
 

 
\t \t <table class="table"> 
 
\t \t \t <thead> 
 
\t \t \t <tr> 
 
\t \t \t <td>Name</td> 
 
\t \t \t <td>Email</td> 
 
\t \t \t <td>ID</td> 
 
\t \t \t </tr> 
 
\t \t \t </thead> 
 
\t \t </table> 
 
\t \t </div> 
 

 
\t \t <input ng-model="test"> 
 
\t \t {{test}} 
 

 

 

 
\t </body> 
 
</html>

+0

你能提供你的控制器的一些例子嗎?也許你的網頁的HTML,看看你是否錯過了別的?像'ng-app'? – JanR

+0

我上傳了我的示例html頁面。這是我的示例控制器。 (){ }() –

回答

0

放在身體的NG-控制器= 「AppCtrl」,因爲你使用的控制器的範圍之外NG-模型。