你能告訴我這段代碼有什麼問題。當我使用$ scope的時候它工作正常,但是當我用下面的代碼替換它時不會。這個角度js代碼有什麼問題(我正在使用這個代替範圍在控制器中)
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl as person">
`<h1>{{person.name}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function() {
var student = {name:"Volvo",
age: 20};
this.student = student;
});
</script>
<p>The property "carname" was made in the controller, and can be referred to in the view by using the {{ }} brackets.</p>
</body>
</html>