VM73:49Uncaught ReferenceError: angular is not defined in jsfiddle
VM73:49Uncaught ReferenceError: angular is not defined in jsfiddle
我正在尝试 运行 js 中的 angularJS 示例 fiddle(当然是学习目的)在控制台中出现以下错误。
当我添加此 cdn 以实现 angular 兼容性时:
https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.6/angular.min.js
我看到以下错误。
VM141 angular.min.js:6 Uncaught Error: [$injector:modulerr]
http://errors.angularjs.org/1.5.6/$injector/modulerr?p0=myApp&p1=Error%3A%2…oudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.5.6%2Fangular.min.js%3A21%3A19)
当我删除外部源时,看到以下错误:
VM93:45 Uncaught ReferenceError: angular is not defined
关注:
- 我需要为 angular 示例添加外部源吗?如果是,那么添加外部资源的正确方法是什么。 (例如,搜索那个 api 的 cdn 并添加)。
这是代码片段:
html:
<div ng-app="myApp" ng-controller="myCtrl">
Your name: <input type="text" ng-model="name" ng-click="displayName();">
Hello {{$scope.name}}
</div>
js:
var myApp = angular.module('myApp', []);
myApp.controller('myCtrl', function($scope){
$scope.displayName = function(){
alert("In right place");
$scope.name = "Name";
}
});
我已将 angular-1.0.1.js
file 添加到外部资源(您只需复制并粘贴 URL),并将 {{$scope.name}}
更改为 {{name}}
在您的 HTML 文件。使用{{
}}
时不必写$scope
,它是隐含的。
这是一个基于您提供的代码的工作 Fiddle。
PS:我添加了Angular 1.0.1,当然你可以使用你想要的Angular版本。可以看到所有releases here.
HTML
<div ng-app="myApp" ng-controller="myCtrl">
Your name: <input type="text" ng-model="name" ng-click="displayName();">
Hello {{name}}
</div>
JavaScript
var myApp = angular.module('myApp', []);
myApp.controller('myCtrl', function($scope) {
$scope.displayName = function(){
alert("In right place");
$scope.name = "Name";
}
});
我正在尝试 运行 js 中的 angularJS 示例 fiddle(当然是学习目的)在控制台中出现以下错误。
当我添加此 cdn 以实现 angular 兼容性时: https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.6/angular.min.js
我看到以下错误。
VM141 angular.min.js:6 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.6/$injector/modulerr?p0=myApp&p1=Error%3A%2…oudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.5.6%2Fangular.min.js%3A21%3A19)
当我删除外部源时,看到以下错误:
VM93:45 Uncaught ReferenceError: angular is not defined
关注:
- 我需要为 angular 示例添加外部源吗?如果是,那么添加外部资源的正确方法是什么。 (例如,搜索那个 api 的 cdn 并添加)。
这是代码片段:
html:
<div ng-app="myApp" ng-controller="myCtrl">
Your name: <input type="text" ng-model="name" ng-click="displayName();">
Hello {{$scope.name}}
</div>
js:
var myApp = angular.module('myApp', []);
myApp.controller('myCtrl', function($scope){
$scope.displayName = function(){
alert("In right place");
$scope.name = "Name";
}
});
我已将 angular-1.0.1.js
file 添加到外部资源(您只需复制并粘贴 URL),并将 {{$scope.name}}
更改为 {{name}}
在您的 HTML 文件。使用{{
}}
时不必写$scope
,它是隐含的。
这是一个基于您提供的代码的工作 Fiddle。
PS:我添加了Angular 1.0.1,当然你可以使用你想要的Angular版本。可以看到所有releases here.
HTML
<div ng-app="myApp" ng-controller="myCtrl">
Your name: <input type="text" ng-model="name" ng-click="displayName();">
Hello {{name}}
</div>
JavaScript
var myApp = angular.module('myApp', []);
myApp.controller('myCtrl', function($scope) {
$scope.displayName = function(){
alert("In right place");
$scope.name = "Name";
}
});