我新的角度和我有一个问题。
I'm new to angular and i have a question.
即时通讯使用1.3.11版本的棱角分明。
Im using 1.3.11 version of angular.
香港专业教育学院写了一个简单的HTML code,它是使用简单的角度和即时得到以下错误:
Ive wrote a simple html code that that using simple angular and im getting the following error:
参数myController的'是不是一个功能,AngularJS得到未定义[复制]
Argument 'MyController' is not a function, got undefined in AngularJS [duplicate]
在html code是:
the html code is:
<!DOCTYPE html>
<html ng-app>
<head>
<meta charset="UTF-8">
<title>Angular Demo</title>
<script src="lib/angular/angular.min.js">
</script>
</head>
<body>
<div ng-controller = "MyController">
<h1> {{author.name}}</h1>
<p> {{author.title + ', ' + author.company}}</p>
</div>
<script>
function MyController($scope)
{
$scope.author= {
'name' : 'Naim',
'title' : 'MR',
'company' : 'Naimos'
}
}
</script>
</body>
</html>
感谢您提前。
有工作plunker
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="UTF-8" />
<title>Angular Demo</title>
<script data-require="angular.js@*" data-semver="1.3.11"
src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.js"
></script>
</head>
<body>
<div ng-controller="MyController">
<h1> {{author.name}}</h1>
<p> {{author.title + ', ' + author.company}}</p>
</div>
<script>
function MyController($scope)
{
$scope.author= {
'name' : 'Naim',
'title' : 'MR',
'company' : 'Naimos'
}
}
angular
.module('app', [])
.controller("MyController", MyController)
</script>
</body>
</html>
检查角模块的定义:
Check the definition of the angular module:
angular
.module('app', [])
.controller("MyController", MyController)
和也,模块应用程序如今被注入INT HTML
And also, the module "app" is now injected int html
<html ng-app="app">
检查它在行动这里