我对 Angular js 很陌生(4 小时的经验),所以我会直接说:
我正在编写在线类(class)的基本示例,该类(class)录制于 2014 年。
问题是 Controller 内的函数没有执行,我知道我错过了一些非常基本的东西,但我在 StackOverflow 上搜索了相关问题,但没有帮助,所以我依赖。
这是代码片段:
<!DOCTYPE html>
<!-- the index.html file -->
<html ng-app="myApp">
<head>
<title>Angular Udemy chap 2</title>
<script src="angular.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<div ng-controlller="mainController">
<h1> Hello {{ name }} !!! </h1>
</div>
</body>
/* the app.js file */
var myApp = angular.module('myApp',[]);
myApp.controller('mainController',["$scope",function($scope){
$scope.name = "ElBarto";
}]);
最佳答案
您将 ng-controller
拼写为 ng-controlller
。修正拼写错误,一切都应该正常。
关于javascript - 为什么 Controller 函数不执行 Angular Js 1.5.5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36802984/