Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 简单角度模块工作不正常_Javascript_Html_Angularjs_Module - Fatal编程技术网

Javascript 简单角度模块工作不正常

Javascript 简单角度模块工作不正常,javascript,html,angularjs,module,Javascript,Html,Angularjs,Module,所以我尝试用我的angular js做一个小的测试应用 {{firstName+“”+lastName} 在身体和这个 <script> var testapp = angular.module("testApp",[]); testapp.controller("myCtrl",function ($scope) { $scope.firstName = "John"; $scope.lastName = "Doe

所以我尝试用我的angular js做一个小的测试应用


{{firstName+“”+lastName}
在身体和这个

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

var testapp=angular.module(“testapp”,[]);
testapp.controller(“myCtrl”,函数($scope){
$scope.firstName=“John”;
$scope.lastName=“Doe”;
});
这就是它的下场。但是,我仍然收到以下信息:


我怎样才能让它显示我想要的东西,即“约翰·多伊”?我知道我可能做了一些简单的错误…

您的代码在代码段编辑器中运行良好。 你能发布更多细节吗

请在下面找到工作示例
var testapp=angular.module(“testapp”,[]);
testapp.controller(“myCtrl”,函数($scope){
$scope.firstName=“John”;
$scope.lastName=“Doe”;
});

{{firstName+“”+lastName}

控制台中有错误吗?可能没有加载Angular。@FrankModica yes:错误:[$controller:ctrlreg]在Angular.min.js:6在Angular.min.js:93在ba(Angular.min.js:76)在n(Angular.min.js:68)在g(Angular.min.js:61)在g(Angular.min.js:62)在Angular.min.js:61在m.$eval(angular.min.js:148)(匿名)@angular.min.js:123对我的代码的快速更正无法解决问题,但testapp和testapp的名称不同,我已经修复了。但结果仍然相同。你能在Plunker中发布你的代码吗?控制台中是否有任何错误。另外,请检查angular是否已加载。希望这个Plunker能给你一些想法
//Create a seperate js file named module.js in which add your code as below
var testapp = angular.module("testApp",[]);
  testapp.controller("myCtrl",function ($scope) {
      $scope.firstName = "John";
      $scope.lastName = "Doe";
  });

//then inject module.js file below the angular.min.js and please make 
//angular.min.js locally because it won't work when you will offline