<html ng-app>
<body >
<div ng-controller="SimpleController">
Name: <input type="text" ng-model="name">
</br>
{{name}}
</br>
<ul >
<li ng-repeat="p in customers |filter:name | orderBy:'name'">{{p.name|uppercase }} .{{p.city}}
</li>
</ul>
</div>
<script src="angular.min.js"></script>
<script >
function SimpleController($scope){
$scope.customers=[
{name:'Apu',city:'jsr'},
{name:'Gapu',city:'gujarat'},
{name :'Papu', city:'gIndia'}
]
}
</script>
</body>
</html>
答案 0 :(得分:0)
可能检查你的angularjs版本,对于1.3以上的版本,不支持全局控制器。
var app = angular.module("app", []);
app.controller("SimpleController", ["$scope",
function($scope) {
$scope.customers=[
{name:'Apu',city:'jsr'},
{name:'Gapu',city:'gujarat'},
{name :'Papu', city:'gIndia'}
]
}
]);
&#13;
<!DOCTYPE html>
<html>
<head>
<script data-require="angular.js@1.4.7" data-semver="1.4.7" src="https://code.angularjs.org/1.4.7/angular.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body ng-app='app'>
<div ng-controller="SimpleController">
<ul >
<li ng-repeat="p in customers |filter:name | orderBy:'name'">{{p.name|uppercase }} .{{p.city}}
</li>
</ul>
</div>
</body>
</html>
&#13;