I have a scenario for deleting items.
For this, first I get a list of values with particular condition. The retrieved values whill be shown in the UI with radio buttons to choose the particular item to choose for deleting.
I have given the value for the radio buttons to be the id of the retrieved items. This id is used in angularJS method for deleting. Currently getting undefined value in the angular function inside the controller.
My angular controller is as below:
mainApp.controller("deleteToDoController", function($scope,$http) {
$scope.toDoList = {};
$scope.getToDo = function(){
var url = "http://localhost:8080/webservice-4.0/rest/todo/"+$scope.status;
$http.get(url)
.then(function(response) {
$scope.toDoList = angular.fromJson(response.data);
});
}
$scope.deleteToDo = function(){
var url = "http://localhost:8080/webservice-4.0/rest/todo/delete/"+$scope.deleteId;
$http.get(url)
.then(function(response) {
$scope.toDoList = angular.fromJson(response.data);
});
}
});
My html page code is :
<div ng-controller="deleteToDoController">
<form ng-submit="getToDo()">
ToDo Status:
<input type="radio" ng-model="status" value="completed"/>Completed<input type="radio" ng-model="status" value="pending"/>Not Completed
<input type="submit" value="View To Do"/><br>
<div ng-repeat = "toDo in toDoList">
<input type="radio" ng-model="deleteId" value=""/>Task : <br>
</div>
<input type="button" ng-click="deleteToDo()">Delete</button><br>
</form>
Appreciated!!!!
Source: AngularJS
from Angular Questions https://angularquestions.com/2017/10/14/value-in-angular-scope-getting-undefined/
via @lzomedia #developer #freelance #web #lzomedia.com
No comments:
Post a Comment