AngularJS APPAngularJS:應用功能2路數據與重擲按鈕(reloadRoute ??)結合
我想知道我怎麼能解決這個無限循環消化這個問題,我應該寫一條件?
目標是使用角度的2路數據綁定,但我需要修改輸出以隨機排序字母。
我的HTML:
<div class="container-fluid phrase-container text-center">
<!-- == User Phrase Input == -->
<input type = "text" ng-model = "phrase.firstPhrase" placeholder="Please enter phrase"><br><br>
</div>
<div class="container-fluid anagram-container text-center">
<!-- == Final anagram == -->
Anagram: {{phrase.fullAnagram()}}
</div>
我的javascript:
var app = angular.module("app", []);
app.controller('mainController', function($scope) {
$scope.main = {};
$scope.main.title = "AnagramJS";
// Refresh Page acts as reroll button
$scope.reloadRoute = function() {
$route.reload();
};
// Anagram Creation
$scope.phrase = {
firstPhrase: "",
fullAnagram: function() {
var finalPhrase;
finalPhrase = this.firstPhrase.split('').sort(function() {
return 0.5 - Math.random()
}).join('');
return finalPhrase
}
};
});
我如何添加一個重擲按鈕只會再次訴諸字?換一個不同的謎語 – FreshOceans