gpt4 book ai didi

angularjs - AngularJS 的 Firebug 中关于 ng-options 的奇怪错误

转载 作者:行者123 更新时间:2023-12-02 04:50:36 25 4
gpt4 key购买 nike

当我使用 Angular 的 ng-options 时,我得到了这个奇怪的错误:

Error: [ngOptions:iexp] Expected expression in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got 'playlist.id as playlist.name in playlists | orderBy: 'playlist''. Element: <select class="ng-pristine ng-valid" name="playlist" ng-model="playlist" ng-options="playlist.id as playlist.name in playlists | orderBy: 'playlist'">

我的代码是:

<select name="playlist" ng-model="playlist" ng-options="playlist.id as playlist.name in playlists | orderBy: 'playlist'"></select>
<button class="btn btn-branded" ng-click="postSongToPlaylist(playlist.id);">Save</button>

ng-model 指的是这个文件:

    MediaService.getPlaylists().then(function (response) {
$scope.playlists = response.data.data;
});

$scope.postSongToPlaylist = function(playlist_id) {
media = {
id: $rootScope.song_id
};
MediaService.postSongToPlaylist(playlist_id, media).then(function (response) {});
}

最佳答案

正确的语法是playlist.id as playlist.name for playlist in playlists | ...

关于angularjs - AngularJS 的 Firebug 中关于 ng-options 的奇怪错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18922860/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com