2015-04-05 85 views
0

这里我有一些代码不工作,我不知道为什么。任何人都可以帮我吗?AngularJS DataBinding不起作用

<!DOCTYPE html> 
<html>   
    <head data-ng-app=""> 
     <title>Directives and Data Binding angular_js</title> 
    </head>   
    <body data-ng-init="names=['John Smith','John Doe','Jane Doe']">Name: 
     <br/> 
     <input type="text" data-ng-model="name" />{{ name }} 
     <ul> 
      <li data-ng-repeat="person in names"></li> 
     </ul> 
     <script src="angular.min.js"></script> 
    </body>  
</html> 

http://postimg.org/image/pi38k566f/

我使用的歌剧,我也试过在Mozilla Firefox。

回答

0

这工作 - Plunker

data-ng-app=""应该是在身体标记:

<!DOCTYPE html> 
<html> 
    <head> 
     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> 
     <title>Directives and Data Binding angular_js</title> 
    </head> 
    <body data-ng-app="" data-ng-init="names=['John Smith','John Doe','Jane Doe']"> 
    Name:<br/><input type="text" data-ng-model="name"/>{{ name }} 
     <ul> 
      <li data-ng-repeat="person in names">{{person}}</li> 
     </ul> 
    </body> 
</html> 

我在重复添加{{person}}来显示阵列数据。

+0

哦谢谢。我是初学者,所以我希望你能原谅这样的错误:D再次感谢你。 – 2015-04-08 11:48:30