AngularJS Big Issue 1.1.5升级到1.3.8(必须简单):/

Tow*_*mmy 1 upgrade angularjs

我完全不知道这里可能出错了什么.

使用1.1.5版本,一切都完美无瑕.

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

升级到1.3.8螺丝我的整个应用程序.

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

获取此错误参数'ContactControllerHeading'不是函数,未定义

html的

<html ng-app="myApp" >
<body>
<div ng-controller="ContactControllerHeading">
...
lots of cool stuff here :)
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

.js文件

var myApp  = angular.module('myApp', []);

  function ContactControllerHeading($scope,$http) {

     $scope.Home = function() {
             ...
             lots of cool stuff :)
      }

}
Run Code Online (Sandbox Code Playgroud)

Phu*_*yen 5

Angular 1.3有一个重大变化:您不再能使用全局功能创建控制器(与任何模块无关的功能)

只需稍作改动,而不是在全局范围内定义控制器,只需在您的应用中定义它:

myApp.controller("ContactControllerHeading", function ($scope, $http) {
   //controller code
});
Run Code Online (Sandbox Code Playgroud)