Angularjs |选中时,ng-repeat设置为true或false

时间:2018-05-23 06:46:33

标签: angularjs

如果在angularjs中选择了某些数据,我该如何设置true或false?

示例我有数据

$scope.obj = {
   'id': 1,
   'id': 2,
   'id': 3
}

<div ng-repeat="myData in ctrl.obj">
   <input type="text" class="form-control" placeholder="Notes" ng-model="ctrl.myData ">
</div>

我想要一些帮助,当我输入数据并且等于id = 1时,它将设置我的值为ID 1,否则它将设置为空,但当我回到我最后选择的输入框时,它仍然会显示我之前输入的输入框的值。感谢协助我的逻辑错误:)

1 个答案:

答案 0 :(得分:2)

检查以下可能对您有帮助的代码:

 /*Programm for making decision on arbitrage betting*/



#include <iostream>
//using namespace ::std;

//Prompting user to select an option.

double what_do_you_want_to_do(int z){
double a, b, c;
std::cout << "What do you want to do" << std::endl;
std::cout << "For calculating Percentage & Profit for a single bet, PRES 1" << std::endl;
std::cout << "For calculating Arbitrage Percentantage & Profit for two odds, PRESS 2" << std::endl;
std::cout << "For calculating Arbitrage Percentantage & Profit for three odds, PRESS 3" << std::endl;
std::cin  >> z;

//Using switch to branch.
switch(z)
 {
    case 1:
    //call function 1
    break;
    case 2:
    //call function 2
    if (z == 2)
    arbitrage_two_diff_odds(a, b, c);
    break;
    case 3:
    //call function 3
    break;
 }
}

 //function for calculation of the arbitrage for two different odds.
 double arbitrage_two_diff_odds(double a, double b, double c){

 //Prompting user for imput.
std::cout << "Enter your values in this format \"1st odd, 2nd odd, investment\": ";
std::cin  >> a >> b >> c;

//Calculating the sum of the percentage of the two different odds.
double diff_two_odds = ((1/a)*100) + ((1/b)*100);

//maniplation
if (diff_two_odds <= 90)
{
    double calc_profit = c/diff_two_odds;
    double idividual_bet1 = (c*((1/a)*100))/diff_two_odds;
    double idividual_bet2 = (c*((1/b)*100))/diff_two_odds;
    std::cout << "The arbitrage odds you put in are "<<a<< "and"<<b<<"."<< std::endl;
    std::cout << "The percentage gain for individual odd are "<<((1/a)*100)<<"% and "<<((1/b)*100)<<"% respectively."<<std::endl;
    std::cout << "The individual bet for your propose investment are "<<idividual_bet1<<"$ for "<<a<< "and "<<idividual_bet2<<"$ for "
    <<b<< "respectively, which equals "<<c<<"."<<std::endl;
    std::cout << "From your proposed investment of "<<c<<"$, Your arbitrage profit is "<<calc_profit<< std::endl;       
}
else
    std::cout << "No profit for the odds entered, try different one again"<< std::endl;
    std::cout << "No profit for the odds entered, try different one again"<< std::endl;

}

 int main()

{

int z = what_do_you_want_to_do(z);

}
var abcAPP = angular.module("abcApp",[]);
abcAPP.controller("abcCtrl",function($scope){
	$scope.obj = [{ 'id': 1}, {'id': 2}, {'id': 3 }]
    $scope.myData = ["1","2","3"];
});