私は工場で工場を作り、それをコントローラで使用しようとしていますが、工場ではgetメソッドからデータを返してコントローラに保存していますが、動作していないので、$ scope.myDataはundefindを返します。コントローラanglejsでの工場の使い方
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, myService) {
$scope.myData = myService.getEvent();
});
app.factory('myService', function($http){
var oGetData = {};
oGetData.getEvent = function(){
$http.get('http://citysdk.dmci.hva.nl/CitySDK/events/search?category=festival')
.then(function(response) {
return response.data.event;
});
};
return oGetData ;
});
私はコントローラに直接その作業罰金を工場出荷時のコードを使用し
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http.get('http://citysdk.dmci.hva.nl/CitySDK/events/search?category=festival')
.then(function(response) {
$scope.myData = response.data.event;
});
});
誰かが私が最初のコードで間違ってください何をしたか私に言うことができますか? http://codepen.io/jdoyle/pen/KgLjgY
これは、よく寄せられる質問です:
はここcodepen http://codepen.io/anon/pen/NRVZdE
このコード出力誤差はTypeErrorを:それが参照しているどのライン未定義 – ahmdabos
の「を」プロパティを読み取ることができませんか?あなたは、見るために羽目板またはコデペンを持っていますか? –
ありがとうございました – ahmdabos