Angular JS 1.3.11:参数' MyController'不是功能 [英] Angular JS 1.3.11: Argument 'MyController' is not a function
本文介绍了Angular JS 1.3.11:参数' MyController'不是功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新来的有角度的人,我有一个问题.
I'm new to angular and i have a question.
我使用的是1.3.11版本的angular.
Im using 1.3.11 version of angular.
我编写了一个简单的html代码,该代码使用简单的angular并收到以下错误:
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代码是:
<!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>
谢谢.
推荐答案
<!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>
检查角度模块的定义:
angular
.module('app', [])
.controller("MyController", MyController)
而且,模块"app"现在被注入了html
And also, the module "app" is now injected int html
<html ng-app="app">
在运行中进行检查此处
这篇关于Angular JS 1.3.11:参数&#39; MyController&#39;不是功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文