HTML
<div ng-controller="BlogData" >
<form ng-submit="removeTodo()">
<ul>
<li ng-repeat="blog in bloges">
{{blog.name}}
<p>{{blog.mobile}}</p>
<p>{{blog.description}}</p>
<input class="btn-primary" type="submit" value="remove">
<p></p>
</li>
</ul>
</form>
<form ng-submit="addTodo()">
<label>Name:</label><input type="text" ng-model="todoName" size="30"
placeholder="add your name">
<label>Mobile:</label><input type="number" ng-model="todoMobile" size="30"
placeholder="add your mobile">
<label>Description:</label><input type="text" ng-model="todoDesc" size="30"
placeholder="add some description">
<hr>
<h1>Hello {{todoName }}!</h1>
<h1>Your mobile is {{todoMobile}}!</h1>
<h1>About my Details :- {{todoDesc}}!</h1>
<input class="btn-primary" type="submit" value="add">
</form>
</div>
JS
function BlogData($scope) {
$scope.bloges = [
{"name": "Nexus S",
"mobile": "858485454",
"description": "The nest to seehow it works"},
{"name": "Motorola XOOM™ with Wi-Fi",
"mobile": "8584453454",
"description": "The nest to ytrb dsfhgs gvd m seehow it works"},
{"name": "MOTOROLA XOOM™",
"mobile": "443485454",
"description": "The nest bla bla vd fg hvto seehow it works"}
];
$scope.addTodo = function() {
$scope.bloges.push({name:$scope.todoName, mobile:$scope.todoMobile, description:$scope.todoDesc, done:false});
$scope.todoName = '';
$scope.todoMobile = '';
$scope.todoDesc = '';
};
$scope.removeTodo = function() {
$scope.bloges.pop({name:$scope.todoName, mobile:$scope.todoMobile, description:$scope.todoDesc, done:false});
$scope.todoName = '';
$scope.todoMobile = '';
$scope.todoDesc = '';
};
}
var blogApp = angular.module('blogApp',[]);
blogApp.controller('BlogData', BlogData);
I am facing problem while deleting the element. When I am clicking a remove its removing the last element. I tried splice as well but not able to reach success.
Here is a Fiddle
Some concern related Angular implementations :-
We need to use form action
ng-submit="addTodo()"
or we need to use<button ng-click="addTodo(">
please differentiate.Can anyone define the proper scoping in angular with practical manner in full flex web application ?
Please guide me.. Thanks !!