How do I list what appears on the console in View?

Asked

Viewed 47 times

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);
   }

That returns me on the console the right names:

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

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

I’m doing it this way, but it’s wrong, don’t print it:

<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>
  • Was any of the answer helpful? Don’t forget to choose one and mark it so it can be used if someone has a similar question!

1 answer

1


Change your code from controller for:

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>
  • This way it prints only the letters of the first item.

  • @Ramos adjusted, take a look if it suits you so

Browser other questions tagged

You are not signed in. Login or sign up in order to post.