AngularJS DataBinding is not working



这里有一些代码不起作用,我不知道为什么。有人能帮我吗?

<!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/

我正在使用Opera,我也尝试过Mozilla Firefox。

这是有效的-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>

我在repeat中添加了{{person}}来显示数组数据。

最新更新