javascript - Error using Ionic framework for weather app -
i building weather app using ionic , it's done. have problem wind bearing, in json data have degrees wind direction , have use code it's not showing in current ..
$scope.windbearing = function(windbearing) { if (windbearing < 11.25 && windbearing > 348.75) return '<img alt="" class="center-block" src="http://meteoiraq.com/img/n.png"style="width: 60px;"><h4 class="text-center">الرياح شمالية</h4>'; else if (windbearing > 11.25 && windbearing < 33.75) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/nne.png"style="width: 60px;"><h4 class="text-center">الرياح شمالية شمالية شرقية</h4>'; } else if (windbearing > 33.75 && windbearing < 56.25) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/ne.png"style="width: 60px;"><h4 class="text-center">الرياح شمالية شرقية</h4>'; } else if (windbearing > 56.25 && windbearing < 78.75) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/ene.png"style="width: 60px;"><h4 class="text-center">الرياح شرقية شمالية شرقية</h4>'; } else if (windbearing > 78.75 && windbearing < 101.25) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/e.png"style="width: 60px;"><h4 class="text-center">الرياح شرقية</h4>'; } else if (windbearing > 101.25 && windbearing < 123.75) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/ese.png"style="width: 60px;"><h4 class="text-center">الرياح شرقية جنوبية شرقية</h4>'; } else if (windbearing > 123.75 && windbearing < 146.25) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/se.png"style="width: 60px;"><h4 class="text-center">الرياح جنوبية شرقية</h4>'; } else if (windbearing > 146.25 && windbearing < 191.25) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/s.png"style="width: 60px;"><h4 class="text-center">الرياح جنوبية</h4>'; } else if (windbearing > 191.25 && windbearing < 213.75) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/ssw.png"style="width: 60px;"><h4 class="text-center">الرياح جنوبية جنوبية غربية</h4>'; } else if (windbearing > 213.75 && windbearing < 236.25) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/sw.png"style="width: 60px;"><h4 class="text-center">الرياح جنوبية غربية</h4>'; } else if (windbearing > 236.25 && windbearing < 258.75) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/wsw.png"style="width: 60px;"><h4 class="text-center">الرياح غربية جنوبية غربية</h4>'; } else if (windbearing > 258.75 && windbearing < 281.25) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/w.png"style="width: 60px;"><h4 class="text-center">الرياح غربية</h4>'; } else if (windbearing > 281.25 && windbearing < 303.75) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/wnw.png"style="width: 60px;"><h4 class="text-center">الرياح غربية شمالية غربية </h4>'; } else if (windbearing > 303.75 && windbearing < 326.25) { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/nw.png"style="width: 60px;"><h4 class="text-center">الرياح شمالية غربية</h4>'; } else { return '<img alt="" class="center-block" src="http://meteoiraq.com/img/nnw.png"style="width: 60px;"><h4 class="text-center">الرياح شمالية شمالية غربية</h4>'; } }
code html
<div>{{windbearing(weatherinfo.currently.windbearing)}}<div>
binding {{text}} syntax inserts text, not compiled html @misha130 said, , see markup , not intended image.
you need bind using ng-bind-html instead. replace div above following:
<div ng-bind-html="windbearing(weatherinfo.currently.windbearing)"></div>
if $sce:unsafe error, means need sanitize html first. do this, include script angular-sanitize , inject ngsanitize module.
Comments
Post a Comment