javascript - Want to add string to HTML from AJAX request in AngularJS -
i want make weather app ajax request , not strong in angularjs. have :
http://jsfiddle.net/6458vz1s/1/
and can't add locationhtml
html ng-bind-html
. causes errors this:
when add ng-bind-html-unsafe
, there no errors , still no html
when print through console.log
, looks perfect. can't add html
add 'ngsanitize'
module's dependencies
check documentation here : https://docs.angularjs.org/api/ng/directive/ngbindhtml
weatherapp=angular.module('weatherapp',['ngsanitize']); weatherapp.controller('weathercontroller', function($scope,$http){ $http.get('http://api.wunderground.com/api/key/forecast/geolookup/conditions/q/ca/san_francisco.json').success(function(response){ $scope.weather = response; $scope.locationhtml = "in next 2 boxes see weather conditions in <b>" + $scope.weather.location.city + "</b> city"; }) .error(function(response){ alert('error occured weather app') }); });
Comments
Post a Comment