bagai mana cara agar satu controller audio tapi bisa untuk banyak lagu

saya punya projek audio tapi controller audio nya terlalu banyak jadi saya mau jadikan satu controller untuk semua lagu contoh scrip controller lagunya

.controller("audioTest",function($scope,ngAudio){
        $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/02%20-%20Surah%20an-Naba.mp3");
    $scope.playSound = function(){
      $scope.audio.play();
}
})

.controller("audioTest2",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/03%20-%20Surah%20an-Naaziaat.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})

.controller("audioTest3",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/04%20-%20Surah%20Abasa.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})

.controller("audioTest4",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/05%20-%20Surah%20at-Takweer.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest5",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/06%20-%20Surah%20al-Infitaar.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest6",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/07%20-%20Surah%20al-Mutaffiffeen.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest7",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/08%20-%20Surah%20Inshiqaaq.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest8",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/09%20-%20Surah%20al-Burooj.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest9",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/10%20-%20Surah%20at-Taariq.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest10",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/11%20-%20Surah%20al-Alaa.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest11",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/12%20-%20Surah%20al-Ghaashiyah.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest12",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/13%20-%20Surah%20al-Fajr.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest13",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/14%20-%20Surah%20al-Balad.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest14",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/15%20-%20Surah%20ash-Shams.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest15",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/16%20-%20Surah%20al-Layl.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest16",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/17%20-%20Surah%20ad-Duhaa.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest17",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/18%20-%20Surah%20ash-Sharh.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest18",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/19%20-%20Surah%20at-Teen.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest19",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/20%20-%20Surah%20al-Alaq.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest20",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/21%20-%20Surah%20al-Qadr.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest21",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/22%20-%20Surah%20al-Bayyinah.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest22",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/23%20-%20Surah%20az-Zalzaalah.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest23",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/24%20-%20Surah%20al-Aadiyaat.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest24",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/25%20-%20Surah%20al-Qaariah.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest25",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/26%20-%20Surah%20at-Takaathur.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest26",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/27%20-%20Surah%20al-Asr.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest27",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/28%20-%20Surah%20al-Humazah.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest28",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/29%20-%20Surah%20al-Feel.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest29",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/30%20-%20Surah%20Quraysh.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest30",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/31%20-%20Surah%20al-Maaun.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest31",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/32%20-%20Surah%20al-Kawthar.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})

.controller("audioTest32",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/33%20-%20Surah%20al-Kaafirun.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest33",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/34%20-%20Surah%20an-Nasr.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest34",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/35%20-%20Surah%20al-Masad.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest35",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/36%20-%20Surah%20al-Ikhlaas.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest36",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/37%20-%20Surah%20al-Falaq.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})
.controller("audioTest37",function($scope,ngAudio){
      $scope.audio = ngAudio.load("http://muhammadatok.16mb.com/38%20-%20Surah%20an-Naas.mp3");
          $scope.playSound = function(){
            $scope.audio.play();
          }
})

avatar algifari
@algifari

19 Kontribusi 2 Poin

Diperbarui 8 tahun yang lalu

1 Jawaban:

ada contoh kode yang manggil controllernya ? harusnya sih bisa banget jadi dinamis dijadiin argumen/parameter kalo masang controllernya di tiap audio, coba pasang ng-init yang isinya parameternya. Cek link ini coba http://stackoverflow.com/questions/14523679/can-you-pass-parameters-to-an-angularjs-controller-on-creation

avatar hilmanski
@hilmanski

2686 Kontribusi 2135 Poin

Dipost 8 tahun yang lalu

Login untuk ikut Jawaban