How to list in the View what appears in the console?

0

I have this routine:

 $scope.array1 = window.localStorage.getItem("tipos_pagamentos");

    var as_formas_pag = $scope.array1.split(';');        


   for (var i = 0; i < as_formas_pag.length; i++){         
      $scope.array2 = as_formas_pag[i];
       console.log($scope.array2);
   }

It returns the right names on the console:

Dinheiro
Cartão Visa Crédito
Cartão Master Crédito

How do I do ng-repeat and print in the View these results?

I'm doing this, but it's wrong, it does not print:

<ion-list ng-repeat="r in array2 track by $index">
              <ion-radio ng-model="checkItems[r.i]" ng-value="'{{r.i}}'">{{r.i}}</ion-radio>             
          </ion-list> 

          <button class="button button-full button-assertive" ng-click="pegaFormaPagamento(checkItems[r.i])"  >
              CONTINUAR
          </button>
    
asked by anonymous 22.01.2017 / 15:39

1 answer

1

Change your code from controller to:

var tipos = window.localStorage.getItem("tipos_pagamentos");
$scope.tipos= tipos .split(';');

And change your HTML to the following:

<div class="list list-inset" ng-repeat="tipo in tipos">
  <ion-radio ng-model="escolhido" ng-value="$index">{{tipo}}</ion-radio>
</div>
    
22.01.2017 / 16:28