<html ng-app>
<head>Angular Model</head>
<body>
<p>
<input ng-model="greeting.text"/>
<p>{{greeting.text}}, AngularJS</p>
</p>
<p ng-controller="HelloAngular">
<p>{{greetingCon.text}}, AngularJS</p>
</p>
</body>
<script src="js/angular.js"></script>
<script src="js/HelloAngular_MVC.js"></script>
</html>
function HelloAngular($scope){
$scope.greetingCon = {
text: 'Hello'
};
}
过去多啦不再A梦2017-06-10 09:50:09
var app = angular.module("myApp", []);
app.controller("HelloAngular", ['$scope', function($scope) {
$scope.greetingCon = {
text: 'Hello'
};
}])
Try to see if you can get the value
高洛峰2017-06-10 09:50:09
Because your current writing method can run before 1.3.0. If your Angular version is after 1.3.0-beta.15, writing this way will not work.
Here is the official changelog, the description has been selected: https://github.com/angular/an...
Therefore, you need to mount controller
under a module
It is also mentioned that you can add $controllerProvider.allowGlobals();
to config
to allow global function, but it is not recommended