Hi ,
I m write a code I m showing the two section and one form for add new text in my projects.
But i have two major Problem .
is if i click to edit button than show the form but if i change any text in form than i click to save button there is a nothing happen .
is if i fill the data in new form and just press submit button not add the data in my top li Please check this and solve my problem .
Thanks in advanced Please help me
My Code is here
Angular Code is this
var app = angular.module('myApp', []);
app.controller('mySearchController', function($scope) {
$scope.searhBars = [{
title: "fiel 1",
description: 'What do you want'
}, {
title: "fiel 2",
description: "I want to this"
}, {
title: "fiel 3",
description: "Why do you want me "
}];
$scope.formSubmit = function(searhBar) {
showForm = false;
};
$scope.newItemAdd = function(title, description) {
if (this.newName === '') return;
$scope.searhBar.push({
title: title,
description: description
});
this.newName = '';
this.newDes = '';
};
});
HTML Code is
<body ng-app="myApp">
<ul ng-controller="mySearchController">
<li>Hello</li>
<li ng-repeat="searhBar in searhBars">
<h4 ng-show="!showForm">{{searhBar.title}}</h4>
<p ng-show="!showForm">{{searhBar.description}}</p>
<button ng-show="!showForm" ng-click="showForm=true">Edit me</button>
<form ng-submit="formSubmit(searhBar)" ng-show="showForm">
<label>Field 1.
<input type="text" ng-model="searhBar.title" />
</label>
<label>Enter Description
<textarea ng-model="searhBar.description"></textarea>
</label>
<input type="submit" value="Save" />
</form>
</li>
<li>
<form ng-submit="newItemAdd(newName, newDes)">
<label>Field
<input type="text" ng-model="newName" />
</label>
<label>Enter Description
<textarea ng-model="newDes"></textarea>
</label>
<input type="submit" value="submit" />
</form>
</li>
</ul>
</body>