As a newcomer to AngularJS (and JavaScript in general), I'm currently facing an issue that I could use some help with.
Below is the HTML template I am using:
<ion-view view-title="Playlists">
<ion-content>
<ion-list>
<ion-item ng-repeat="playlist in playlists" ng-init="pageID=playlist.id" href="#/app/music/{{playlist.id}}">
{{playlist.title}} {{pageID}}
</ion-item>
</ion-list>
</ion-content>
</ion-view>
And this is the corresponding controller:
.controller('MusicCtrl', function($scope) {
$scope.playlists = [
{ title: 'Reggae', id: 1 },
{ title: 'Chill', id: 2 },
{ title: 'Dubstep', id: 3 },
{ title: 'Indie', id: 4 },
{ title: 'Rap', id: 5 },
{ title: 'Cowbell', id: 6 }
];
$scope.$watch('pageID', function () {
console.log($scope.pageID);
});
Although {{pageID}} appears correctly on the page, it seems undefined when checked in the console. Can anyone point out what mistakes I might be making here?