Angular初心者です。
javascript
1angular.module('mainApp', []) 2.service('example', function ($http) { 3 this.methodA = function () { 4 $http({ 5 method : 'GET', 6 url : "http://hogehoge.com/fuga"; 7 }).success(function(data, status, headers, config) { 8 alert(data); 9 }).error(function(data, status, headers, config) { 10 console.log(status); 11 }); 12 } 13}) 14.controller('hogeCtrl', ['$scope', 'example', function ($scope, example) { 15 example.methodA(); 16}]); 17 18
こんな感じの処理を書いて、http通信の処理結果をalertで出力するというのは成功したのですが、
このdata内の文字列データをreturnで返してコントローラーに渡す、という方法がわかりません。。。
どのような形になるのでしょうか?
ちなみにAngular.jsのバージョンは1.4.5です。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。