我如何确保我做按钮将迎来特定任务的要求做的。 [英] How do I make sure that my do button will mark the specific task as requested do.
问题描述
我所列举的任务,每个任务都有一个既做按钮和基金按钮。
当我点击执行按钮或基金的按钮,我想具体的任务被分配到DoRequested或FundingProposed的状态。我只是不知道如何将这些状态添加到我的情况的具体型号。
由于我是新来的角度,我对如何做到这一点不知道。
下面是我的看法code迄今:
< DIV NG-应用=facebookExample视图标题=任务>
< DIV NG控制器=todoController>
< H1>任务和LT; / H1> < DIV CLASS =逐项输入-插图>
<标签类=项,输入包装>
<! - 这是使用NG-模式绑定到todoInput实际输入标签 - >
<输入类型=文本占位符=添加新项NG模型=todoInput大小=100>
< /标签>
<! - 我们的按钮大公将调用我们的funtion添加一个新的待办事项 - >
<按钮类=按钮按钮小NG点击=todoAdd()>
添加任务
< /按钮>
< / DIV> < DIV NG重复=X在todolist的>
<李班=项项,勾选>
&安培; NBSP;&安培; NBSP;&安培; NBSP;<标签类=复选框>
< /标签>
<! - 这是复选框元素,你会看到它被绑定到完成项目阵列中的设置 - >
<! - 当点击它调用更新功能的项目更新到其DONE状态 - >
<输入类型=复选框NG模型=x.doneNG点击=更新()/>
<! - 这是一个span标签,显示项文本,我使用的NG-绑定,而不是span标签我们可以使用{{x.todoText}},以及 - >
<按钮类=基金按钮style =浮动:左; NG-点击=基金(X)>&基金LT; /按钮>
<跨度> {{x.todoText}}< / SPAN>
<按钮类=doButton的风格=浮动:权利;保证金右:2px的; NG-点击=做(X)>走走LT; /按钮>
< /李>
< / DIV>
<! - 删除按钮将调用remove函数和remoave被标示为已完成的所有项目 - >
<按钮类=按钮按钮按钮块张扬NG点击=删除()>删除选中的任务
< /按钮>
< / DIV>
< / DIV>
和我的控制器:
facebookExample.controller('todoController',['$范围',函数($范围){
//初始化待办事项列表数组
//如果本地存储为空保存todolist的本地存储
$ scope.todoList = [];如果(localStorage.getItem(mytodos)===空)
{ localStorage.setItem(mytodos,angular.toJson($ scope.todoList)); }其他
{
//设置从本地存储的todolist的
$ scope.todoList = angular.fromJson(localStorage.getItem(mytodos));
}
//添加一项功能
$ scope.todoAdd =功能(){
//检查是否文本已经输入,如果不退出
如果($ scope.todoInput ===空|| $ scope.todoInput ===''){回报;} //如果有文本它添加到阵列
$ scope.todoList.push({todoText:$ scope.todoInput,做到:假}); //清除文本框
$ scope.todoInput =; //重新保存列表localStorage的
localStorage.setItem(mytodos,angular.toJson($ scope.todoList));
}; //每个任务被限制为限制资金总额= $ 1000个
//目前的资金;最大的资金;巴伦斯资金= $ 1000电流
//变量或列taskX/ **************** /
//任务柜台Task X所
//如果任务分配由管理员aproved
//设置任务柜台D-63
//发送提醒指派人在到期日Task X所
//为了钱按钮diabled除非任务属内资
//做免费总是处于启用状态,除非任务已分配
/ ************** /
//更新任务的状态,做只在到期日
//如果DTIME>截止日期
// UserX可以更新任务,做起来难 //联系是由行动收到电子邮件通知 //管理员应在3日内aprove disaprove的 //管理员可以aprove到做或撤消 / ******************* /
//任务的X管理员aproves到DONE
//任务X被更新为完成状态
//如果moeny和募集金额为任务> //付款发起塔斯克如果任务提供资金,为钱做
从公司倡导管理员//付款,如果任务免费做
//完成按钮
$ scope.do =功能(){
//如果当前用户点击执行,
//将当前用户的任务与正在等待管理员aproval状态 //柜台海杜特日期变量与D-63启动
}; $ scope.doForFree =功能(){ //任务被分配给用户使用的待定aproval - 的 - 管理 - 转让-DO换自由状态
//管理员通知做换自由请求 }; //如果管理员aproves的要求做任务赚钱X的用户
//任务X被分配给该用户
//任务状态分配给管理员,aproved赋值换金钱
//通知用户管理aproval的
//任务到期日创建/更新
//如果管理员aproves的要求做免费的任务X的用户
//任务X被分配给该用户
//任务状态分配给管理员,aproved赋值换自由
//通知用户管理aproval的
//任务到期日创建/更新
//基金按钮 $ scope.fund =功能(){ //重定向当前用户的PayPal支付给您,即成
//最高支付限额不能超过最高限额 - 的东西已经获得资助
//需要保持已获资助金额的轨道
//需要跟踪任务的成本/价格 //如果支付宝付款成功完成
//更新已资助金额
//更新一笔额外资金最高限额
//更新充分的资金变量/布尔
//发送任务/用户/量数据库 //如果付款失败,取出被资助的状态
}; $ scope.remove =功能(){
//副本列表
VAR oldList = $ scope.todoList;
//清晰的列表
$ scope.todoList = [];
//通过列表循环
angular.forEach(oldList,功能(X){
//添加任何非做项目的待办事项列表
如果$ scope.todoList.push(X)(x.done!);
});
//更新本地存储
localStorage.setItem(mytodos,angular.toJson($ scope.todoList));};//更新功能
//这等待100毫秒,以存储在本地存储中的数据
$ scope.update =功能(){
//更新本地存储的复选框后100毫秒被点击,以允许它处理
的setTimeout(函数(){
localStorage.setItem(mytodos,angular.toJson($ scope.todoList));
},100);
};}]);
因此,从通过你的code将其快速阅读,似乎你想要的是由来处理特定项目NG-点击= 这样做(X)
并将其添加到DoRequested
或FundingProposed
所以,简单的方法是通过它你做了正确的 NG-点击
通过该项目。因此,修改脚本是这样的:
$ scope.DoRequested = []; $ scope.fund =功能(X){
。
。
。
$ scope.DoRequested.push(X);
的console.log($ scope.DoRequested);
}
现在每次单击该基金按钮, X
添加到阵列。
下面是一个小提琴
I have tasks listed and each task has both a "Do" button and a "Fund" button. Once I click on the "Do" button or "fund" button, I want the specific task to be assigned to a state of "DoRequested" or "FundingProposed". I just do not know how to add these states to the specific model in my case.
As I am new to angular, I have no idea on how to do this.
Here is my view code so far:
<div ng-app="facebookExample" view-title="Tasks">
<div ng-controller="todoController">
<h1>Tasks</h1>
<div class="item item-input-inset">
<label class="item-input-wrapper">
<!-- The actual input tag which is bound to the todoInput using ng-model -->
<input type="text" placeholder="Add New Item" ng-model="todoInput" size="100">
</label>
<!-- Our button thay will call our funtion to add a new todo item -->
<button class="button button-small" ng-click="todoAdd()">
Add Task
</button>
</div>
<div ng-repeat="x in todoList">
<li class="item item-checkbox">
<label class="checkbox">
</label>
<!-- this is the checkbox element, you will see it is bound to the done setting in the items array -->
<!-- When clicked it calls the update function to update the item to its done status -->
<input type="checkbox" ng-model="x.done" ng-click="update()"/>
<!-- this is a span tag that shows the item text, I am using ng-bind, instead of the span tag we could have used {{x.todoText}} as well -->
<button class="fund-button" style= "float: left;" ng-click="fund(x)">Fund</button>
<span>{{x.todoText}}</span>
<button class="doButton" style= "float: right; margin-right: 2px;" ng-click="do(x)">Do</button>
</li>
</div>
<!-- the remove button will call the remove function and remoave all items that are marked done -->
<button class="button button-block button-assertive" ng-click="remove()">Remove Checked Tasks
</button>
</div>
</div>
And my controller:
facebookExample.controller('todoController', ['$scope', function($scope) {
// Initialize the todo list array
//if local storage is null save the todolist to local storage
$scope.todoList = [];
if (localStorage.getItem("mytodos") === null)
{
localStorage.setItem("mytodos", angular.toJson($scope.todoList));
}else
{
//set the todolist from local storage
$scope.todoList = angular.fromJson(localStorage.getItem("mytodos"));
}
// Add an item function
$scope.todoAdd = function() {
//check to see if text has been entered, if not exit
if ($scope.todoInput === null || $scope.todoInput === ''){return;}
//if there is text add it to the array
$scope.todoList.push({todoText:$scope.todoInput, done:false});
//clear the textbox
$scope.todoInput = "";
//resave the list to localstorage
localStorage.setItem("mytodos", angular.toJson($scope.todoList));
};
// Each task is limited to limit total funding = $1000
//current funding ; max funding; ballance funding = $1000-current
// Variables or columns for taskX
/****************/
// Task Counter for Task X
// If task-assignment is aproved by admin
// Set Task Counter to D-63
// Send reminder to Person assigned for task X in Due Date
// Do for money button is diabled unless task is funded
// Do for free is always enabled unless task is already assigned
/**************/
//Updating state of task to done only on due date
// if Dtime > DueDate
// UserX can update task to done
// Admin is notified by email of the action
// Admin should aprove of disaprove within 3 days
// Admin can aprove to Done or Undone
/*******************/
// Admin aproves of Task X to done
// Task X is updated to state of done
//if for moeny and amount raised for task >
// Payment is initiated to Tasker if task was funded and done for money
// Payment initiated from Company to Admin if task was done for free
//Do button
$scope.do = function(){
// If current user clicks do,
// Assign the current user to the task with a state of pending admin aproval
// Counter variable for dute date is initiated with D-63
};
$scope.doForFree = function(){
// Task is assigned to user with a state of pending-aproval-of-admin- assignment-do-for-free
// Admin is notified of do-for-free-request
};
// if admin aproves user that requested to do task X for money
// task X is assigned to that user
// state of task is assigned to admin-aproved-assignment-for-money
// the User is notified of admin aproval
// Task due date is created/updated
// if admin aproves user that requested to do task X for free
// task X is assigned to that user
// state of task is assigned to admin-aproved-assignment-for-free
// the User is notified of admin aproval
// Task due date is created/updated
//fund button
$scope.fund = function(){
//Redirect current user to paypal for payment to You-Serve
// Maximum payment cannot exceed Maximum amount - what 's already funded
// Need to keep track of already funded amount
// Need to keep track of task cost/price
// If paypal payment was done successfully
// Update already funded amount
// Update maximum amount for extra funding
// update the fully funded variable/boolean
// Send task/user/amount to database
// If payment fails, take out state of being funded
};
$scope.remove = function() {
//copy list
var oldList = $scope.todoList;
//clear list
$scope.todoList = [];
//cycle through list
angular.forEach(oldList, function(x) {
//add any non-done items to todo list
if (!x.done) $scope.todoList.push(x);
});
//update local storage
localStorage.setItem("mytodos", angular.toJson($scope.todoList));
};
//The Update function
//This waits 100ms to store the data in local storage
$scope.update = function() {
//update local storage 100 ms after the checkbox is clicked to allow it to process
setTimeout(function(){
localStorage.setItem("mytodos", angular.toJson($scope.todoList));
},100);
};
}]);
So from a quick read through your code it seems what you want is to process the specific item by ng-click="do(x)"
and add it to "DoRequested"
or "FundingProposed"
So the simplest way would be to pass the item via ng-click
which you did correctly. So modify the script to something like this :
$scope.DoRequested = [];
$scope.fund=function(x){
.
.
.
$scope.DoRequested.push(x);
console.log($scope.DoRequested);
}
now each time you click the fund button , x
is added to array.
Here's a fiddle
这篇关于我如何确保我做按钮将迎来特定任务的要求做的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!