Below is the code I am using to add a new task:
<fieldset>
<legend>Create New Task</legend>
<input type="text" ng-model="subtaskname" placeholder="Subtask Name" ><br />
<select id="s1" ng-model="selectedItem" ng-options="item as item.name for item in items"></select>
<button type="button" ng-click="addTask()">Add Task</button>
</fieldset>
To display a table with the data, use the following code:
<table border="1" cellpadding="10">
<thead>
<tr>
<th>
Name
</th>
<th>
Age
</th>
<th>
Title
</th>
<th>
</th>
</tr>
</thead>
<body>
<tr ng-repeat="data in activity">
<td>
{{ data.subTaskNames }}
</td>
<td>
<select ng-model="data.taskShedule" ng-options="item as item.name for item in items track by item.id"></select>
</td>
<td>
<button type="button" ng-click="removeTask($index)">Remove Task</button>
</td>
</tr>
</body>
</table>
Working example: http://plnkr.co/edit/BoJzDAL8jXYUw1mb9dYK?p=preview
I have an input box and a select box at the top to add subtask names and task schedules to the table.
When adding new data, it should only be added if the task schedule value is not already present. If the selected task schedule already exists, then the new row should not be added, and the subtask name should be stored inside the string[].
For example, if a user tries to add a subtask name while selecting "Schedule 1" or "Schedule 3", the new row should not be added because those schedules are already taken. However, if the user selects "Schedule 2", then a new row can be added.
I need assistance in storing the subtask names into the existing string[] when new data is added with an existing schedule. If there is no existing data available with the selection, then a new row can be added.