AngularJS - Textarea在点击后不想清除

时间:2017-02-18 14:23:11

标签: javascript html angularjs

我的textarea有问题。

当我想用ng-click清除她时,没有任何反应......

你能帮助我吗?

这是我的代码,您可以使用Jsfiddle进行测试:My app

如果您愿意,请点击此处:

HTML:

<div ng-controller="Ctrl1">
        <div><textarea id="yourid" ng-model="isWriting" ng-change="writeEvent(isWriting)"></textarea>
        <span ng-if="displaySend == 1">Yann says :</span> {{isWriting}}
      <p ng-click="sendYaah(isWriting); isWriting == ''">YAH!</p>
</div>

JS:

$scope.writeEvent = function(isWriting) {

  $scope.imWriting = isWriting;
  var empty = "";

  if ($scope.imWriting != empty){
    $scope.displaySend = 1;
    // $scope.waitResponse = true;
  } else {
    $scope.displaySend = 0;
    // $scope.waitResponse = false;
  }

}

感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

==

中将=(相等运算符)更改为ng-click(赋值运算符)
isWriting == ''

isWriting = ''

Forked Fiddle