I have 2 pages and I want to pass a variable from page 1 to page 2.
page1.html
<ion-view ion-title="Home">
<ion-content>
<label class="item item-input">
<input type="text" placeholder="Enter a value" ng-model="value">
</label>
<button class="button button-block button-positive" ng-click="me(value)" >
Go to List
</button>
</ion-content>
</ion-view>
this is the controller , I use $state to go to page 2 and I use $rootscope to be able to use the value in the page2Controller
angular.module('starter.controllers', [])
.controller('page1Ctrl', function($rootScope ,$state ) {
$rootScope.me = function(value)
{
$rootScope.value= value;
$state.go('page2');
};
});
the problem is , when I click the button in page 1 it doesn't take me to page2 where is the mistake
this is states code
.config(function($stateProvider, $urlRouterProvider){
$stateProvider
.state('page1', {
url: '/page1',
templateUrl: 'templates/page1.html', controller: 'page1Ctrl'})
.state('page2', {
url: '/page2',
templateUrl: 'templates/page2.html', controller: 'page2Ctrl'})
$urlRouterProvider.otherwise('/page1');})