我正在做一个游戏,我需要让用户在完成前一个关卡后选择下一个关卡。这可以上升到第7级。
我需要能够改变按钮上的文字,以表明下一个标签号高达7。
所以,在控制器中,我需要读取之前显示的按钮文本,以便显示下一个数字。
有人能帮忙吗?这是我的密码笔
codepen link
以及迄今为止我尝试过的附带代码
<html ng-app="myApp">
<body ng-controller="myCtrl">
<div id="nextlevel">
<h3>Level Completed!</h3>
<button id="nextplay" ng-model="number" ng-init="buttontext='Level
2'">{{buttontext}}</button>
</div>
</body>
</html>
和管制员-
myApp = angular.module("myApp",[]);
myApp.controller("myCtrl", function($scope){
document.getElementById("nextplay").addEventListener('click', function() {
nextlevel.style.display = 'none';
setTimeout(function() {
nextlevel.style.display = '';
}, 500);
if ($scope.number <=7) {
$scope.number = $scope.number + 1;
}
el.emit('gameStarted', {});
});
$scope.buttontext = "Level " + $scope.number;
});
我不知道如何将按钮文本的值更新为下一个值。