私はこのサービスを作成しました。 ** enrollments.getProperty(); **このサービスを呼び出すにはこのステートメントを使用していますが、機能していません。私はangle-JSの新機能です。 service
とfactory
: Angular JSサービス作成エラー
var helloAjaxApp = angular.module("myApp", []);
helloAjaxApp.service('enrollments', [ '$scope', '$http', function ($scope, $http) {
\t
\t $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=utf-8";
var enrollments = null;
enrollment();
$scope.enrollment=function() {
\t $http({
\t url : 'enrollments',
method : "GET"
}).then(function(response) {
\t enrollments = response.data;
alert("enrollments");
});
};
return {
getProperty: function() {
return enrollments;
},
setProperty: function(value) {
\t enrollments = value;
}
};
}]);
をコントローラにパラメータとして渡す必要がありサービス名ですか? –
var helloAjaxApp = angular.module( "myApp"、[]); – RD063
あなたは何を得ていますか? – Nitheesh