我想通过单击事件更改 angularjs (1.x) 工厂中的变量。之后应该会出现暂停按钮。请你帮助我好吗:
带有 ng-click 的链接:
<li ng-click='navPlayMusic()'>
<a class="glyphicon glyphicon-play music-control"></a>
</li>
<li ng-show="musicControl.playTitle === true" ng-click='navPauseMusic()'>
<a class="glyphicon glyphicon-pause music-control"></a>
</li>
编辑:
控制器:
music.controller('musicController', function($scope, $rootScope, $location, musicControl) {
...
$scope.musicControl = musicControl;
$scope.navPlayMusic = function() {
musicControl.playMusic();
}
...
});
工厂:
music.factory('musicControl', function () {
return {
playTitle: false,
};
this.playMusic = function() {
return {
playTitle: true
};
};
});