我的app.js文件中有这个简单的代码:
(function(){
var app = angular.module('searchHotels', []);
app.controller = ("PlaceController", function(){
this.place = shop;
});
var shop = {
name: 'supermarket',
distance: 100
};
})();
Run Code Online (Sandbox Code Playgroud)
这是index.html文件的代码:
<!doctype.html>
<html ng-app="searchHotels">
<head>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body>
<div ng-controller="PlaceController as placeC">
<h3> {{placeC.place.name}} </h3>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在输出中,我的{{placC.place.name}}表达式不会被它要显示的数据所取代.它只输出" {{placeC.place.name}} "本身.我在这里错过了什么?谢谢!