Skip to content Skip to sidebar Skip to footer

AngularJS Display List Right Below The URL

So I am trying to display a list of values on the front end right below where they are clicked. For instance, lets say my front end has a list of albums: album-name-1 album-name-2

Solution 1:

I think you should have markup like this

<ul>
    <li ng-repeat="album in vm.albums">
        <a ng-click="vm.getAlbumTracks(album, $index);">{{album}}</a>
        <ul ng-show="$index === vm.showingAlbumIndex">
            <li ng-repeat="track in vm.albums.tracks"><a ng-click="vm.displayForm(track)">{{track}}</a></li>
        </ul>
    </li>
</ul>
<a ng-click="vm.newFunction('RAVI')">Click Me!</a>

In function controller, assign property vm.showingAlbumIndex

function getAlbumTracks(album, index){
    vm.showingAlbumIndex = index;
    //...
}

Post a Comment for "AngularJS Display List Right Below The URL"