简体   繁体   中英

Angular.js Hello World difference between 1.2.0 and 1.4.7

I have a really simple Angular.js Hello World application. When I include version 1.2.0 the application works but when I include 1.4.7 the application does not work.

<body ng-app>

<!-- works with 1.2.0 -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>

<!-- Does not work with with 1.4.7 -->
<!--script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script-->


<div ng-controller="AppCtrl">
    Hello {{name}}
</div>

<script type="text/javascript">
    var app = angular.module('app',[]);

    function AppCtrl($scope) {
        $scope.name = 'Sally';
    }
</script>

</body>

Can someone help me with what might be wrong here?

thanks

That format is no longer supported from 1.3.x

You have to complete process in order to continue

Like this

<body ng-app='app'>

<!-- works with 1.2.0 -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>

<!-- Does not work with with 1.4.7 -->
<!--script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script-->


<div ng-controller="AppCtrl">
    Hello {{name}}
</div>

<script type="text/javascript">
    var app = angular.module('app',[]);
    function AppCtrl($scope) {
        $scope.name = 'Sally';
    }
    app.controller("AppCtrl",AppCtrl);
</script>

</body>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM