I am a newbie to Angular. I am using a controller and I am initially loading the page using the init function. I have an element on html that activates the incrementPage function. When I activate the function, the init function executes again and I get the same result instead of the next page. How do I solve this issue?
myApp.controller('MusicController', ['$scope',  '$resource', function($scope, $resource){
      var vm = $scope;
      init();
      function init(){
      vm.pgno = 1;
      music = $resource('http://104.197.128.152:8000/v1/tracks/', {"page": vm.pgno}).get({"page": vm.pgno});
      vm.tracks = music;
      }
      vm.incrementPage = function(){
        vm.pgno = vm.pgno + 1;
        console.log(vm.pgno);
        music = $resource('http://104.197.128.152:8000/v1/tracks/', {"page": vm.pgno}).get({"page": vm.pgno});
        vm.tracks = music;
        console.log(vm.pgno);
      };
    }]);
Also, I am using ngRoute and two different controllers.
    myApp.config(['$routeProvider', function($routeProvider) {                        
      $routeProvider                                                                
           .when('/', {                                            
             templateUrl: "views/listMusic.html",                                               
             controller:'MusicController',                                
            })
            .when('/genres', {                                            
             templateUrl: "views/genres.html",                                               
             controller:'MusicGenreController',                                
            })                                                                       
    }]);
    myApp.controller('MusicGenreController', ['$scope', 'tracklister', function($scope, tracklister) {
      var vm = $scope;
      var gpgno = 1;
      var incrementGPage = function(){
        gpgno += 1;
        gen = tracklister.genreList.get({'page': gpgno});
        vm.genres = gen;
      }
      (function(){
        gen = tracklister.genreList.get({'page': gpgno});
        vm.genres = gen;
      })();
    }]);
When I click the <a href="#genres">Genres</a> instead of taking me to the genres view it is getting me back to the same listMusic view inside the first MusicController controller. What to do here?
    <!DOCTYPE html>
    <html ng-app='ListTracksApp'>
      <head>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-route.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-resource.js"></script>
        <script src="appl.js"></script>
        <meta charset="utf-8">
        <link rel="stylesheet" href="styles.css">
        <title>Music</title>
      </head>
      <body>
        <h1>Music Tracks</h1>
        <a href="#genres">Genres</a>
        <div ng-view>
        </div>
      </body>
    </html>
 
     
    