为什么我的Plunker Angular JS无效?

时间:2016-06-16 18:52:04

标签: angularjs plunker

有人能告诉我为什么这个掠夺者不能工作吗? Sample AngularJS on Plunker

HTML:

<!DOCTYPE html>
<html>

  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.6/angular.min.js"></script>
    <script src="script.js"></script>
  </head>

  <body ng-controller="MyCtrl">
    <p>{{userData}}</p>
  </body>

</html>

JavaScript的:

var app = angular.module('myApp', []);
app.controller('MyCtrl', function ($scope) {
  $scope.userData = {
    name: 'Xavier',
    age: 25
  }
});

1 个答案:

答案 0 :(得分:1)

你忘了把ng-app。

<html ng-app="myApp">