Javascript 使用角度1插值将动态值传递给函数参数
我有一个函数,根据某个值更改按钮的文本Javascript 使用角度1插值将动态值传递给函数参数,javascript,html,angularjs,Javascript,Html,Angularjs,我有一个函数,根据某个值更改按钮的文本 $scope.text = 'Wait'; if(Number($scope.x) == Number($scope.y)) $scope.text = 'Go' else if(Number($scope.x) < Number($scope.y) $scope.text = 'Wait' 按钮上的文本,继续功能正在执行。如果文本为等待,我想停止调用继续函数。为了做到这一点,我尝试了类似的方法 $scope.check = fu
$scope.text = 'Wait';
if(Number($scope.x) == Number($scope.y))
$scope.text = 'Go'
else if(Number($scope.x) < Number($scope.y)
$scope.text = 'Wait'
按钮上的文本,继续
功能正在执行。如果文本为等待,我想停止调用继续
函数。为了做到这一点,我尝试了类似的方法
$scope.check = function(val) {
if(val == 'Go') {
$scope.proceed();
}
}
我在HTML中使用它,就像
<button type="submit" ng-click="check({{text}})">{{text}}</button>
我想知道是否还有其他更好的方法。任何帮助都将不胜感激。此时不需要插入文本,只需将其传递给函数即可。 即:
{{text}}
不要这样传递文本
将其更改为:
<button type="submit" ng-click="check(text)">{{text}}</button>
{{text}
这将解决您的错误
Error: [$parse:syntax]
<button type="submit" ng-click="check(text)">{{text}}</button>