首页 > 解决方案 > onclick url未定义的Angular js

问题描述

显示专辑列表,但我希望能够单击表中的专辑并在同一页面上显示曲目列表。当我这样做时,网址显示“ http://localhost/cm0665-assignment/#/album/undefined ”。

我认为这与“专辑代码”有关。但不确定该怎么做。

javascript

$scope.selectedalbum = {};
$scope.selectAlbum = function ($event, album){
     $scope.selectedAlbum = album;
     $location.path('/album/' + album.albumCode);
};

html

<table>
    <tr data-ng-repeat="album in albums"
        data-ng-click="selectAlbum($event, album)"
        data-ng-class="{'selected':selectedAlbum.albumCode===album.album_id}"
        style="cursor: pointer;">
        <td>{{album.album_id}}</td><td>{{album.Name}}</td>
    </tr>
</table>

标签: phphtmlangularjs

解决方案


推荐阅读