Hi I am a newbie in rails.
I have implemented a timezone for a website and I have made a drop down box via javascript.
The problem I am having is I am able to select the values but I am not able to display the selected value in drop down.. The value in the dropbox is constant..
<div class='select-drz' ng-controller="AppController">
<a class='btn' id='drz' timezone> TESTING <span class='arrow'></span></a>//want to implement dynamic code here
</div>
Also I am getting the value for dropdown by implementing cookie like the below code:-
Arab.controller('AppController', ['$scope', '$rootScope', '$route', 'userAPI', 'recoAPI', 'autoAPI','$location', function($scope, $rootScope, $route, userAPI, recoAPI, autoAPI,$location){
// array of API calls & pattern string stored
$scope.autoComplete = {
data: [],
lastQuery: '' ,
previousQueries:[]
};
$scope.timezone_as_per_city = [{city: '(GMT+4:00) Abu Dhabi' , timezone: '240',number: '0',gmt: '+4.0'}, / Timezone to be implemented
{city: '(GMT+3:30) Tehran',timezone: '210',number: '1',gmt: '+3.30'},
{city: '(GMT+3:00) Kuwait',timezone: '180',number: '2',gmt: '+3.0'},{city: '(GMT+3:00) Riyadh',timezone: '180',number: '3',gmt: '+3.0'},
{city: '(GMT+2:00) Amman',timezone: '120',number: '4',gmt: '+2.0'},{city: '(GMT+2:00) Beirut',timezone: '120',number: '5',gmt: '+2.0'}
];
if($.cookie('timezone_city'))
{
$scope.city = $scope.timezone_as_per_city[$.cookie('number')];
//$.cookie('timezone_city',JSON.stringify($scope.timezone_as_per_city[$.parseJSON($.cookie('timezone_city')).number]), {expires:365});
$.cookie('timezone_city',$scope.timezone_as_per_city[$.cookie('number')].city, {expires:365});
$.cookie('timezone',$scope.timezone_as_per_city[$.cookie('number')].timezone, {expires:365});
$.cookie('number',$.cookie('number'), {expires:365});
$.cookie('gmt',$scope.timezone_as_per_city[$.cookie('number')].gmt, {expires:365});
}
else
{
// $.cookie('timezone_city',JSON.stringify({city:'(GMT+3:00) Riyadh',timezone: '180',number: '0',gmt: '+3.0'}), {expires:365});
$.cookie('timezone_city','(GMT+3:00) Riyadh', {expires:365});
$.cookie('timezone','180', {expires:365});
$.cookie('number','0', {expires:365});
$.cookie('gmt','+3.0', {expires:365});
$scope.city = $scope.timezone_as_per_city[3];
}
$scope.setTimezone = function(city,timezone,number,gmt){
//$.cookie('timezone_city',JSON.stringify(city), {expires:365});
$.cookie('timezone_city',city, {expires:365});
$.cookie('timezone',timezone, {expires:365});
$.cookie('number',number, {expires:365});
$.cookie('gmt',gmt, {expires:365});
$route.reload("/#!" + $location.path());
};
I am getting the perfect value in the cookie.
The javascript file is as follows:-
<li ng-repeat="l in timezone_as_per_city" >
<span >
<label for="checkbox{{l.city.replace(' ','')}}" >
{{ l.city }}
</label>
<div class="custom-checkbox">
<input ng-click="setTimezone(l.city,l.timezone,l.number,l.gmt)" id="checkbox{{l.city.replace(' ','')}}" />
</div>
</span>
</li>
The only query I am having is that the value or the city selected by the cookie needs to be displayed instead of testing ..
Please help me out am stuck on it