简单角度模块无法正常工作

时间:2017-06-06 15:26:04

标签: javascript html angularjs module

所以我试图使用角度js做一个小测试应用程序

<div ng-app="testApp" ng-controller="myCtrl"> {{firstName + " " + lastName}} </div> 在身体和这个

<script>
      var testapp = angular.module("testApp",[]);
      testapp.controller("myCtrl",function ($scope) {
          $scope.firstName = "John";
          $scope.lastName = "Doe";
      });
  </script>

正是这样。但是,我仍然收到这个:

enter image description here

我怎样才能让它显示我想要的东西&#34; John Doe&#34;?我知道我可能做了一些简单的错误......

2 个答案:

答案 0 :(得分:0)

您的代码在代码段编辑器中运行良好。 您能否发布更多详情

请在下面找到工作示例

&#13;
&#13;
var testapp = angular.module("testApp",[]);
      testapp.controller("myCtrl",function ($scope) {
          $scope.firstName = "John";
          $scope.lastName = "Doe";
      });
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="testApp" ng-controller="myCtrl">
    {{firstName + " " + lastName}}
  </div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

{{1}}