2015-07-15 2 views
0

Предположим, у меня есть вход, где я прошу пользователя поставить только букву карты. Скажем, «KdKc». Помимо отображения пользователя KDKC/kdkc/KdKc, я хотел бы показать юникод для костюмов. K ⋄ K ♣Вход в unicode в mysql и угловом

Кто-нибудь знает, как это сделать?

Я вставив его в таблицу, как это:

$hand = json_decode(file_get_contents("php://input"),true); 
     $hand_names = array('handNumber', 'hand'); 
     $keys = array_keys($hand); 
     $columns = ''; 
     $values = ''; 
     foreach($column_names as $desired_key){ // Check the hand received. If blank insert blank into the array. 
      if(!in_array($desired_key, $keys)) { 
       $$desired_key = ''; 
      }else{ 
       $$desired_key = $hand[$desired_key]; 
      } 
      $columns = $columns.$desired_key.','; 
      $values = $values."'".$$desired_key."',"; 
     } 
     $query = "INSERT INTO hands_table(".trim($columns,',').") VALUES(".trim($values,',').")"; 
     if(!empty($hand)){ 
      $r = $this->mysqli->query($query) or die($this->mysqli->error.__LINE__); 
      $success = array('status' => "Success", "msg" => "Hand Created Successfully.", "data" => $hand); 
      $this->response($this->json($success),200); 
     }else 
      $this->response('',204); //"No Content" status 

и показывая через нг-повторить

<tr ng-repeat="data in customers"> 
      <td>{{data.hand}}</td> 
      <td><a href="#/edit-hand/{{data.handNumber}}" class="btn">&nbsp;<i class="glyphicon glyphicon-edit"></i>&nbsp; Edit Hand</a></td> 
     </tr> 

Я ценю время!

ответ

0

Как насчет создания фильтра? Работа plunker

app.filter('cardSymbol', function() { 
    return function(input) { 
    if (!input) { 
     return input; 
    } 
    input = input.replace(/s/g, '\u2660'); 
    input = input.replace(/h/g, '\u2665'); 
    input = input.replace(/d/g, '\u2666'); 
    input = input.replace(/c/g, '\u2663'); 
    return input; 
    } 
}); 
+0

Не может быть лучше! Благодаря!!! – spaceman