【发布时间】:2015-09-30 13:26:44
【问题描述】:
每次我保存 myApp.js 时,CodeKit 都会给我一个警告。当我通过 CodeKit 预览加载 index.html 时,firstName 和 lastName 变量看起来很好。我只是想让这个问题消失。
"var app = angular.module("myApp", []);
'angular' is not defined"
这是我的两个文件 index.html 和 myApp.js
index.html:
<html>
<script src="angular/angular.js"></script>
<script src="myApp.js"></script>
<body ng-app="myApp" ng-controller="myCtrl">
<div>
{{ firstName + " " + lastName }}
</div>
</body>
</html>
myApp.js:
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.firstName = "John";
$scope.lastName= "Doe";
});
【问题讨论】:
-
你试过把 ng-app="myApp" 放在 标签里吗?
-
与 ng-app @RenanLopesFerreira 无关
-
@RenanLopesFerreira 是的,我刚刚尝试过,但仍然收到警告。
-
你检查到
angular.js的路径了吗? -
<script src="angular/angular.js"></script>好吗?我的意思是angular文件夹中有一个文件名angular.js在.html页面的根文件夹中的位置吗?
标签: javascript angularjs codekit