Found a code doing a to do list.
$scope.tasks = [];
$scope.searchEnter = function() {
if(event.which == 13 && $scope.task !="") {
$scope.addTask();
};
};
$scope.addTask = function() {
$scope.tasks.push({'taskMessage':$scope.task, 'done':false});
console.log($scope.tasks);
$scope.task = "";
};
$scope.clearCompleted = function() {
$scope.tasks = $scope.tasks.filter(function(item){
return !item.done;
});
};
Was thinking about using it in a project where data is gathered from an API call.
How should data fetched with an API call be implemented into the to do list function? The data is in $rootScope.data and lets say it should be possible to store an attribute like data.id in the to do list.
Tried something like this without any results.
<tr ng-repeat="x in data.list">
<button ng-click="add()">Add!</button>
<td>
<input type="checkbox" ng-model="x.done" />
{{ x.id }}
</td>
API call
$scope.q ="";
$scope.searchData = function(url, id, callBack, apiCall, promise) {
var url="http://api.openweathermap.org/data/2.5/find?q="+$scope.q+"&type=like";
var id = APPKEY;
var callBack = "&callback=JSON_CALLBACK";
var apiCall = url + id + callBack;
if($scope.q.length >= 3) {
var promise = $http.jsonp(apiCall);
promise.success(function(data){
$rootScope.data = data;
console.log($rootScope.data);
});
};
Want the users to be able to pick attributes and store them by their own liking.