未捕获ReferenceError:未定义角度。 (由新手发布)

时间:2018-07-30 10:19:31

标签: javascript angularjs compiler-errors

嗨,我是AngularJs的新手。我遇到错误:

  

“未捕获的ReferenceError:未定义角度。”

我试图找到错误,但找不到。谢谢。 我写的代码是:-

<html ng-app="firstApp">

<body ng-controller="firstController">
  Enter 1st name:<input type="text" ng-model="firstName" />
  <br/> Enter last Name:<input type="text" ng-model="lastName" />
  <br>
  <button ng-click="getFullName()">Get Full Name</button>
  <hr/> Full Name:<label ng-bind="fullName"></label>
  <script scr="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
  <script>
    var app = angular.module("firstApp", []);
    app.controller("firstController", function($scope) {
      $scope.firstName = "";
      $scope.lastName = "";
      $scope.fullName = "";
      $scope.getFullName = function() {
        $scope.fullName = $scope.firstName + "" + $scope.lastName;
      };
    });
  </script>
</html> 

2 个答案:

答案 0 :(得分:1)

您有一个小的错字,应该是src而不是scr

DEMO

<html ng-app="firstApp">
<body ng-controller="firstController">
Enter 1st name:<input type="text" ng-model="firstName"/>
<br/>
Enter last Name:<input type="text" ng-model="lastName"/>
<br>
<button ng-click="getFullName()">Get Full Name</button>
<hr/>
Full  Name:<label ng-bind="fullName"></label>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
    <script>
    var app= angular.module("firstApp",[])
    app.controller("firstController",function($scope)
    {
        $scope.firstName="";
        $scope.lastName="";
        $scope.fullName="";
        $scope.getFullName=function()
        {
            $scope.fullName=$scope.firstName+""+$scope.lastName;    
        };
    });
</script>
</body>

答案 1 :(得分:0)

在加载角度库之前,您的代码正在执行。有时从云加载的库需要花费一些时间才能加载到浏览器中。

请在本地获取角度库,然后尝试从本地加载文件。