Doro Doro - 2 months ago 16x
Javascript Question

AngularJS duplicate rows error

When I want to add the same information it warm me an error of duplicates row.

This problem it comes from $scope.showSal and ng-repeat="rows in showSal".

If I use ng-repeat="rows in showSal track by $index" I can not add duplicate rows and I need it.

How I can make to parse and add duplicates? I tried to make JSON data, but it take error even I use stringify and parse method... maybe I doesn't implemented too well the parsing...

PS: I need to parse an array of objects.

HTML file:

<!DOCTYPE html>
<html lang="en">
<title>Research project</title>
<script src=""></script>
<script src="js/app/research.js"></script>
<body ng-app="testApp" ng-controller="mainCtrl">
<tr ng-repeat="rows in showSal">

<form id="add-content" ng-controller="addInfoCtrl" ng-submit="addInfoDb()">
<div class="controls">
<button type="submit" style="width: 220px;">Adauga salariu</button>

JavaScript file:

var app = angular.module("testApp", []);

app.controller('mainCtrl', ['$scope', '$sce', '$document', function($scope, $sce, $document) {
$scope.showSal = [
{ id: '1', an: '2016', den: 'Oracle' },
{ id: '2', an: '2016', den: 'Oracle' }

app.controller('addInfoCtrl', ['$scope', function($scope) {
$scope.testAdd = { id: '100', an: '2016', den: 'Oracle' }

$scope.addInfoDb = function() {






Here's the working FIDDLE