Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将记录添加到动态表(使用AngularJS)将重新加载整个页面_Javascript_Angularjs_Angularjs Ng Repeat_Reload_Dynamic Tables - Fatal编程技术网

Javascript 将记录添加到动态表(使用AngularJS)将重新加载整个页面

Javascript 将记录添加到动态表(使用AngularJS)将重新加载整个页面,javascript,angularjs,angularjs-ng-repeat,reload,dynamic-tables,Javascript,Angularjs,Angularjs Ng Repeat,Reload,Dynamic Tables,表尾用于向表中添加新记录。通过单击按钮添加后,新记录实际上会添加到表体,但最多会添加一秒钟,然后重新加载整个页面,插入的记录将消失 表是从准备好的数据数组正确创建的 删除记录很好 哪里有问题?我不想重新加载页面 表: <table class="table"> <thead> <tr> <th>Nazwa tchnologii</th>

表尾用于向表中添加新记录。通过单击按钮添加后,新记录实际上会添加到表体,但最多会添加一秒钟,然后重新加载整个页面,插入的记录将消失

  • 表是从准备好的数据数组正确创建的
  • 删除记录很好
哪里有问题?我不想重新加载页面

表:

<table class="table">
            <thead>
            <tr>
                <th>Nazwa tchnologii</th>
                <th>Poziom zaawansowania</th>
                <th>-</th>
            </tr>
            </thead>

            <tfoot>
            <tr>
                <!--Text for new record-->
                <th><input type="text" ng-model="nazwaTechnologii" class="form-control"></th>
                <!--Button to add-->
                <th><button ng-click="dodaj()" class="btn btn-success btn-sm">Dodaj!</button></th>
            </tr>
            </tfoot>

            <tbody id="cialoTabeli">
            <tr ng-repeat="technologia in technologie track by technologia.id" id="{{technologia.id}}">
                <td>{{technologia.nazwa}}</td>
                <!--Button to remove-->
                <td><input type="button" ng-click="usunTechnologie(technologia.id)" class="btn btn-danger btn-sm">Usuń!</input></td>
            </tr>
            </tbody>
 </table>
引述:

类型
按钮的类型。可能的值为:提交:按钮 将表单数据提交到服务器如果 未指定属性,或者该属性是动态指定的 已更改为空值或无效值

表示您需要将按钮
类型
设置为
按钮
,以防止页面被“提交”:

Dodaj!
引用:

类型
按钮的类型。可能的值为:提交:按钮 将表单数据提交到服务器如果 未指定属性,或者该属性是动态指定的 已更改为空值或无效值

表示您需要将按钮
类型
设置为
按钮
,以防止页面被“提交”:

Dodaj!

我们能看到更多的HTML和控制器代码吗?我在plunker()中尝试了您的代码,它似乎工作正常,因此可能出现了其他问题-可能是您在表单中包含了所有这些内容,并且无意中提交了表单。我们可以看到更多的HTML和控制器代码吗?我在一个plunker()中尝试了您的代码,它似乎工作正常,因此可能出现了其他问题—很可能您将所有这些都放在表单中,并且无意中提交了表单。
var indeks = 5;
$scope.dodaj = function () {
      $scope.technologie.push({ 'id': ++indeks, 'nazwa': $scope.nazwaTechnologii});
      $scope.nazwaTechnologii='';
};

$scope.technologie = [   //prepared values
    {"id":1,"nazwa":"C++"},
    {"id":2,"nazwa":"java"},
    {"id":3,"nazwa":"Python"},
    {"id":4,"nazwa":"C"}
];