Javascript (angularjs)获得';ReferenceError:$未定义范围';注入控制器时
我一直在努力学习AngularJS。我有一个HTML页面,试图在其中插入模块,但出现错误 主js文件:Javascript (angularjs)获得';ReferenceError:$未定义范围';注入控制器时,javascript,html,angularjs,Javascript,Html,Angularjs,我一直在努力学习AngularJS。我有一个HTML页面,试图在其中插入模块,但出现错误 主js文件: var classificationModule = angular.module('mainapp',[]); classificationModule.controller('firstcontroll',function(){ $scope.text="Goodday" }); HTML页面: <!DOCTYPE html> <html> <he
var classificationModule = angular.module('mainapp',[]);
classificationModule.controller('firstcontroll',function(){
$scope.text="Goodday"
});
HTML页面:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="layout" content="main"/>
<title>Classification Toolkit for Grails</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js"></script>
<asset:javascript src="main.js"/>
</head>
<body >
<div ng-app='mainapp' ng-controller='firstcontroll'>
Hello, {{text}}
</div>
</body>
</html>
我不知道我做错了什么。你应该写信
var classificationModule=angular.module('mainapp',[]);
classificationModule.controller('firstcontroll',函数($scope){
$scope.text=“Goodday”
});代码>
你好,{{text}}
尝试在函数中传递$scope
var classificationModule=angular.module('mainapp',[]);
classificationModule.controller('firstcontroll',函数($scope){
$scope.text=“Goodday”
});代码>
Grails分类工具包
你好,{{text}}
将@scope替换为$scope.@不是一个有效的javascript标记,因此无法执行该操作。出现新的错误。我的老顶是不是有问题?谢谢。我现在明白了
ReferenceError: $scope is not defined