好的我有一些問題與範圍控制器我已經嘗試了很多不同的東西,但它不適用於我聲明的(1.5.8)Angular版本,AngularJS 1.5.8:控制器和範圍
所以這裏是我的代碼的html:
<body ng-app="myApp">
<input type="text" ng-model="query"/>
<select ng-model="order">
<option value="username">Organiser par nom</option>
<option value="content">Organiser par content</option>
</select>
<div ng-controller="CommentsCtrl">
<div ng-repeat="comment in comments |filter:{content: query} |orderBy:">
<p>
<strong>{{comment.username}}</strong><br>
{{comment.content}}
</p>
</div>
</div>
,這是我的Java腳本:
<script>
var myApp = angular.module('myApp',[]);
myApp.controller('CommentsCtrl', ['$scope', function($scope) {
$scope.comments = [
{
"username": "Goodman",
"city": "Bonanza",
"email": "[email protected]",
"content": "naborum ut. Nisi in ex consequat quis sitet exercitation."
},
{
"username": "Holder",
"city": "Lloyd",
"email": "[email protected]",
"content": "naborum ut. Nisi in exunt magna in et exercitation."
}
];
}]);
</script>
它無法顯示範圍的任何想法?
把你的輸入標籤放在你的控制器裏面。 –