我在safariibooks 和第3.1課上關注AngularJS上的視頻教程,即使我具有與視頻中相同的代碼,但我得到了指定的錯誤在標題中。
這裏是我的代碼:
<html ng-app>
<head>
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/bootstrap.css">
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="bootstrap.min.js"></script>
<title></title>
</head>
<body style="padding: 50px">
<div ng-controller = "AlbumListController">
<p><input placeholder="Type to search..." type ="text" ng-model="searchFor" size="30"/></p>
<p>
There are {{ albums.length}} albums available to view:
</p>
<div class="album panel panel-primary" ng-repeat="album in albums | filter:{ title: searchFor} | orderBy: 'date'">
<!-- -->
<div class="panel-heading">
<div style="float: right"> {{album.date}}</div>
{{ album.title }}
</div>
<div class= "description">
{{ album.description}}
</div>
</div>
</div>
<script type="text/javascript">
function AlbumListController ($scope) {
$scope.albums = [ { name: 'madrid1309', title:'Weekend in Madrid', date: '2013-09-01', description: 'FUN FUN FUN FUN'},
{ name: 'iceland1404', title:'Holiday in Iceland', date: '2014-09-01', description: 'FUN FUN FUN'},
{ name: 'thailand210', title:'Sun and fun in Thailand', date: '2012-09-01', description: 'FUN FUN'},
{ name: 'australia', title:'A wedding in Melbourne', date: '2011-09-01', description: 'FUN'}];
}
</script>
</body>
</html>
The code from video - 它應該是相同的我,我們有相同的設置,因爲我也跟着一步從開始步驟,到目前爲止還沒有問題。
我注意到有之前本網站對這個問題的答案,但他們並沒有回答我的問題。
預先感謝您。
如果這是他們如何創建一個控制器,該教程是完全過時的。這將適用於角度1.0。但是現在我們已經達到了1.6,並且5年來發生了很多變化。使用官方文檔。不是一些過時的YouTube教程。 –