Data and parameters between Views [closed]

3

Hello, I'm creating an App with the IONIC Framework. The front is complete. I made the screen transitions using $ stateProvider quietly.

But I need to do the features of the APP and generally need 2 things

1) Pass parameters through href=""

2) Perform certain functions by clicking on the screen transition button and bring the processed information to the new screen

I could not move forward because I do not understand Angular well and the many examples I saw there, did not clarify enough. This is what I have achieved so far:

INDEX.HTML

<body ng-controller="AppController as controller">
<ion-view title="Tela1"><ion-content>
   <a href="#/tela2" ng-click="controller.test1">
      <button class="estilo-botao">TESTE 1</button>
   </a>
   <a href="#/tela2" ng-click="controller.test2">
      <button class="estilo-botao">TESTE 2</button>
   </a>
</ion-content></ion-view>

...

TELA2.HTML

<ion-view title="Tela2"><ion-content>
   <input type="text" value="{{controller.parametro}}" />
</ion-content></ion-view>

APP.JS

...
app.config( function($stateProvider, $urlRouterProvider){
$stateProvider
  .state('tela2',{
        url:'/tela2',
        templateUrl:'views/tela2.html'
  })
...
app.controller('AppController', ['$scope', function($scope){
    parametro = '';
    this.test1 = function(){
       alert('teste1');
       parametro = 'Um';
    };
    this.test2 = function(){
       alert('teste2');
       parametro = 'Dois';
    };
}]);

I've tried a lot of different things, this was the last one. It has already become a Russian roulette.

I did not understand how controls work and the use of $ scope . I've already seen examples using factory and service , even the CodeSchool mini-course did not help me.

Can anyone shed some light on the subject?

    
asked by anonymous 31.12.2015 / 14:34

0 answers