0
当我推入一个新项目的数组它将它添加到最后,无论bpm是什么。一旦我刷新页面,一切正常。角度orderBy不重新排序阵列推
//view
<form ng-submit="add(newSong)">
<input ng-model="newSong.artist" placeholder="Artist..">
<input ng-model="newSong.title" placeholder="Title..">
<input ng-model="newSong.bpm" placeholder="BPM..">
<input ng-model="newSong.key" placeholder="Key..">
<input ng-model="newSong.year" placeholder="Year..">
<button ng-show=''></button>
</form>
<div ng-repeat="song in songs | orderBy:'bpm'">
{{song.bpm}}/{{song.artist}} - {{song.title}}
</div>
//controller
$http.get('/api/songs').success(function(data) {
$scope.songs = data
})
$scope.add = function(newSong) {
var song = {
artist: newSong.artist
, title: newSong.title
, bpm: newSong.bpm
, key: newSong.key
, year: newSong.year
}
$scope.songs.push(song)
$http.post('/api/songs', song).success(function(data) {
console.log(data)
})
}
当我写这plunker一切正常,我不能告诉这有什么错我的环境(v1.2.25)