javascript - AngularJS - Data-binding from JSON string -


I'm completely new to AngularJS and to capture, parsing and displaying data from a SOAP web service I am trying. So far, I can successfully call a public weather service, capture and display the returned XML data, I can convert the XML to JSON string, but to show / force JSON data to me There is no success. Below are my html and js files. Thanks in advance for any advice / suggestions!

MyHelloView.html

  & lt ;! Doctype html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Script language = "javascript" type = "text / javascript" src = "angular.min.js" & gt; & Lt; / Script & gt; & Lt; Script language = "javascript" type = "text / javascript" src = "xml2json.js" & gt; & Lt; / Script & gt; & Lt; Script language = "javascript" type = "text / javascript" src = "MyHelloController.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body ng-app & gt; & Lt; Title & gt; My simple angular app & lt; / Title & gt; & Lt; Div ng-controller = 'MyHttpController' & gt; {{Soap Respence}} & lt; Br / & gt; & Lt; Br / & gt; {{JsonData}} & lt; Br / & gt; & Lt; Br / & gt; WeatherReturn: & lt; Br / & gt; Success: & lt; Input type = "text" ng-model = "json.data.Success" /> & Lt; Br / & gt; Response text: & lt; Input type = "text" ng-model = "jsonData.ResponseText" /> & Lt; Br / & gt; State: & lt; Input type = "text" ng-model = "json.data.state" /> & Lt; Br / & gt; City: & lt; Input type = "text" ng-model = "json.data.city" /> & Lt; Br / & gt; WeatherStationCity: & lt; Input type = "text" ng-model = "jsonString.WeatherStationCity" /> & Lt; Br / & gt; WeatherID: & lt; Input type = "text" ng-model = "json.data.WeatherID" /> & Lt; Br / & gt; Details: & lt; Input type = "text" ng-model = "json.data.Description" /> & Lt; Br / & gt; Temperature: & lt; Input type = "text" ng-model = "jasondataatapment" /> & Lt; Br / & gt; Relativity: & lt; Input type = "text" ng-model = "json.data.RelativeHumidity" /> & Lt; Br / & gt; & Lt; Div ng-repeat = "json.data.fields in field" & gt; {{Field.name}}: & lt; Input type = "text" ng-model = "field.value" & gt; & Lt; / Div & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

MyHelloController.js

function MyHttpController ($ Range, $ http) {$ scope.loaded = false; $ Scope.soapResponse = 'No response yet'; $ Http.get ('http://wsf.cdyne.com//WeatherWS/Weather.asmx/GetCityWeatherByZIP?ZIP=60301'). Then (function (Convert the result) {$ scope.soapResponse = result.data; var x2js = new X2JS (); // XML data to JSON $ scope.jsonData = x2js.xml_str2json (result.data); $ scope Loaded = true;}); }

Your XML is given below, which means that you just need to drag On the data bus side of the JSN object, maybe you will try to put your controller on a module and take the goods in the service ... but you did not ask about it.

  $ scope JsonData = x2js.xml_str2json (result.data). Air Force; & Lt; WeatherReturn xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: xsd = "http://www.w3.org/2001/XMLSchema" xmlns = "http: // ws. Cdyne.com/WeatherWS/"> & Lt; Success & gt; True & lt; / Success & gt; & Lt; Feedback text & gt; City found & lt; / Response text & gt; & Lt; State & gt; IL & lt; / State & gt; & Lt; City & gt; Oak Park & ​​lt; / City & gt; & Lt; WeatherStationCity & gt; Maywood & lt; / WeatherStationCity & gt; & Lt; WeatherID & gt; 14 & lt; / WeatherID & gt; & Lt; Details & gt; Cloud & lt; / Details & gt; & Lt; Temperature & gt; 27 & lt; / Temperature & gt; & Lt; Relative humidity & gt; 63 & lt; / Relative humidity> & Lt; Wind & gt; S9 & lt; / Wind & gt; & Lt; Pressure & gt; 29.95F & lt; / Pressure & gt; & Lt; Visibility / & gt; & Lt; WindChill / & gt; & Lt; Comments / & gt; & Lt; / WeatherReturn & gt;  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -