2017-02-13 21 views
0

我的浏览器只呈现: “{{cust.name + '' + cust.city}}”AngularJS NG-reapeat不会在浏览器中渲染

的index.html

<!DOCTYPE html> 
    <html data-ng-app="demoApp"> 
     <head> 
      <meta charset="utf-8"> 
      <meta http-equiv="X-UA-Compatible" content="IE=Edge"> 


      <title></title> 
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 

      <style> 
       html, body, input, select, textarea 
       { 
        font-size: 1em;    
       } 
      </style> 

     </head> 

     <body> 

      <div data-ng-controller="SimpleController"> 
       Name : 
       <br> 
       <input type="text" data-ng-model="name"> 
       <br> 

       <ul> 
        <li data-ng-repeat="cust in customers">{{ cust.name + ',' + cust.city }}</li> 
       </ul> 
      </div>  

      <script> 

       var demoApp = angular.module('demoApp', []); 

       var controllers = {}; 
       controllers.SimpleController = function ($scope) { 
        $scope.customers = [ 
         {name:'John', city:'Paris'}, 
         {name:'Andy La', city:'Londra'}, 
         {name:'George', city:'Berlin'} 
        ]; 
       }); 

       demoApp.controller(controllers); 

      </script> 

     </body> 
     <script src="Scripts/angular.min.js"></script> 

    </html> 

它的错我的代码?任何ideea我能做什么? 我尝试了其他网站和其他人的其他ideeas,但它不起作用。我不知道做什么了。 我是angularJS的新手!

谢谢!

+1

尝试把你的在标题中,而不是之后你的角度脚本 –

+0

谢谢很多。铅解决:) – Yogi

回答

0

您需要参考的body标签

内angular.js脚本还必须在年底额外paranthesis,将其删除。

DEMO

var demoApp = angular.module('demoApp', []); 
 
var controllers = {}; 
 
controllers.SimpleController = function ($scope) { 
 
    $scope.customers = [ 
 
    {name:'John', city:'Paris'}, 
 
    {name:'Andy La', city:'Londra'}, 
 
    {name:'George', city:'Berlin'} 
 
    ]; 
 
}; 
 
demoApp.controller(controllers);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular.min.js"></script> 
 
<div ng-app="demoApp" ng-controller="SimpleController"> 
 
Name : 
 
    <br> 
 
    <input type="text" data-ng-model="name"> 
 
    <br> 
 
<ul> 
 
    <li data-ng-repeat="cust in customers">{{ cust.name + ',' + cust.city }}</li> 
 
    </ul> 
 
</div>

+0

它的工作!非常感谢你们。小细节改变了一切:)我改变了许多方式的代码,我没有找到pb。 – Yogi

+0

好的!我做到了!再次感谢你! – Yogi