我有一個函數,其中我改變按鈕的文本基於一些值傳遞動態值使用角1個插值
$scope.text = 'Wait';
if(Number($scope.x) == Number($scope.y))
$scope.text = 'Go'
else if(Number($scope.x) < Number($scope.y)
$scope.text = 'Wait'
我然後使用text
在HTML按鈕標籤上的功能參數
<button type="submit" ng-click="proceed()">{{text}}</button>
按鈕上的文字proceed
功能正在發生。如果文本是等待,我想停止呼叫proceed
函數。爲此,我嘗試了這樣的事情。
$scope.check = function(val) {
if(val == 'Go') {
$scope.proceed();
}
}
我用它在HTML類似
<button type="submit" ng-click="check({{text}})">{{text}}</button>
但我得到一個錯誤,指出
Error: [$parse:syntax]
我想如果有這樣做的任何其他更好的辦法。任何幫助都感激不盡。