javascript - 将值设置为 null,或起始值 Angularjs

标签 javascript angularjs input ionic-framework

如何在点击某个按钮后将输入值重置为空值?

空字段:

enter image description here

我想将具有某些值的字段重置回空字段。

enter image description here

HTML:

    <label class="item item-input">
       <input id="tezina" type="number" placeholder="Tezina" ng-model="podaci.tezina">
       </label>
       <label class="item item-input">
       <input id="mamac" type="text" placeholder="Mamac" ng-model="podaci.mamac">
       </label>
       <label class="item item-input">
       <input id="pribor" type="text" placeholder="Pribor" ng-model="podaci.pribor">
       </label>+
<button class="button button-positive" ng-click="isprazniPolja()">Isprazni</button>

我试过(不工作),来自 Controller 的功能:

$scope.isprazniPolja = function() {
$scope.podaci= null;

}

最佳答案

我想你想重置值 你可以这样做

$scope.isprazniPolja = function(){
          $scope.podaci.tezina="";
          $scope.podaci.mamac="";
          $scope.podaci.pribor="";
          }

Plunker

关于javascript - 将值设置为 null,或起始值 Angularjs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36078724/

相关文章:

javascript - 从 angularjs 表单生成 json

javascript - 检查输入字段是否在 vanilla JavaScript 中具有焦点

css - 输入密码和 :after pseudoelement text

c - 在 C 中的 EOF 之后执行

angularjs - 根据大小响应的自定义磁贴

javascript - 将 Canvas 输出图像调整为特定大小(宽度/高度)

javascript - 从列表中删除值

javascript - 在 React.js 中使用相同的索引映射两个数组

javascript - 如何执行每 3 秒返回数组项目的 ng-repeat

javascript - 当 `label` 元素包含子元素 `span` 时,单击标签会触发子元素而不是父元素