3
Hello, I am 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 in general I need two things
1) Pass parameters through href=""
2) Perform certain functions by clicking the screen transition button and bring the processed information to the new screen
I was unable to move forward because I do not understand Angular lavishly and the many examples I have seen there have not clarified enough. That’s what I got 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, that was the last one. It’s already become a Russian roulette.
I didn’t understand how the controls work and the use of $Scope. I’ve seen examples using Factory and service, up to the mini-course of the Codeschool didn’t help me.
Can someone shed some light on the subject?
When Voce makes an application with templates for different views (Views/Templates) on the same page (Single Page Application) by definition at the angle there is no need to pass parameters through href. All communication takes place through events that your controllers fire and capture respectively... is a considerable paradigm shift.
– Roger Barretto
I understood Rogerio. I met a friend who explained me a little more. I’m now bumping into the MVC, because logic (without experience) is a bit confusing to me. I am studying controllers, Factory and services to apply better. Thank you very much!! : D :D
– Rafael de Castro