Reputation: 3
i am very new to ionic and angularjs. i am using ionic 1 and i want to get a value after make a selection from dropdown..after i select and click next button, the other page will show the name of item that i select.this is on first page. on the second page i want it display communication if i select it on 1st page. i know this is the wrong way..can help me?
<label class="item item-input item-select">
<div class="input-label">
Initiative A
</div>
<select>
<option>Communication</option>
<option>Customer</option>
<option selected></option>
</select>
Upvotes: 0
Views: 959
Reputation: 504
You can get the selected option using ng-modal.
<select ng-modal="selectedValue">
<option>Communication</option>
<option>Customer</option>
<option selected></option>
</select>
Now you will get the selected option on controller by $scope.selectedValue.
You can pass this value to next page using $rootScope or as stateParam.
In first controller,
.controller('myCtrl1',function($scope, $rootScope){
$rootScope.myValue = $scope.selectedValue;
})
In second controller,
.controller('myCtrl2',function($scope, $rootScope){
$scope.selectedValue = $rootScope.myValue;
})
You can display this value in second page HTML like {{selectedValue}}
Upvotes: 0
Reputation: 2940
Save the value in $rootScope
.controller('Ctrl_1',function($rootScope){
$rootScope.myValue= "communication(i.e, use ng-modal)"
})
and access it like this
.controller('Ctrl_2',function($rootScope){
alert("what is my value? " + $rootScope.myValue);
})
Upvotes: 2