2
我刚刚开始使用VS2015 ASP.Net5使用Angular。我使用鲍尔检索的角度,当得到一个错误:angular javascript在visual studio 2015中不工作asp.net 5项目使用Bower时
Error: [ng:areq] Argument 'TextController' is not a function, got undefined http://errors.angularjs.org/1.4.3/ng/areq?p0=TextController&p1=not%20a%20function%2C%20got%20undefined
这是我的html代码:
<!DOCTYPE html>
<html ng-app>
<head>
<meta charset="utf-8"/>
</head>
<body ng-controller="TextController">
<p>{{SomeText}}</p>
<!--does not work-->
<script src="lib/angular/angular.js"></script>
<!--works-->
<!--<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"> </script>-->
<script>
function TextController($scope) {
$scope.SomeText = "Go";
}
</script>
</body>
当我使用谷歌角度提供了它的工作原理就像一个魅力。 下面是一个什么样的VS
我缺少什么用鲍尔产生什么样的照片?
UPDATE 这是工作版本感谢Claies:
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="utf-8"/>
</head>
<body ng-controller="TextController">
<p>{{SomeText}}</p>
<!--does not work-->
<script src="lib/angular/angular.js"></script>
<script>
angular.module('myApp', []).controller('TextController', function ($scope) {
$scope.SomeText = "Go";
});
</script>
</body>
</html>
这是一种破坏更改角度1.3.x +。您不能再将控制器声明为全局对象,您必须声明一个模块并将控制器声明为模块的一部分。看到这个答案http://stackoverflow.com/questions/29149665/why-does-ng-controller-not-work-with-function-this-this-example/29149964#29149964 – Claies
作为一个侧面说明,即使该链接谷歌APIS的作品,我会*从来没有*使用角1.0.1任何目的。 – Claies
@Claies这确实是这种情况。我你在这个贫穷的答案我可以给你充分的信贷,谢谢。外卖:不要将它们在印刷之前过时的旧书丢弃 –