0
我有一個控制器設備控制器。我試圖在服務訪問功能,但我得到一個錯誤 - 類型錯誤:DeviceService1.addNewDevice不是一個函數 在ChildScope $ scope.submitDeviceDtls(CreateDeviceCtrl.js:175)服務中定義的函數不是函數angularjs
這裏是我的代碼
$scope.submitDeviceDtls = function() {
if ($scope.isNewDevice) {
DeviceService1.addNewDevice($scope.device).then(
function (res) {
console.log(JSON.stringify(res));
// logic
}
}
}
我有一個服務DeviceService1
function ($http, $q, ApiService, AuthService) {
return {
addNewDevice: function (deviceDtls) {
var deferred = $q.defer();
var payload = new FormData();
payload.append('deviceDtls', new Blob([JSON
.stringify(deviceDtls)], {
type: "application/json"
}));
// payload.append('profilePic', profile_pic);
payload.append('doctorId', AuthService.getDoctorId());
var req = {
method: 'POST',
headers: {
'Content-Type': undefined
},
transformRequest: angular.identity,
responseType: 'arraybuffer',
data: payload
}
ApiService.generic_post('/device/', req).then(
function (res) {
deferred.resolve(res);
}, function (error) {
deferred.reject(error);
}
);
return deferred.promise;
}
return DeviceService1;
有人能幫助我嗎? TIA
你的意思是出口DeviceService1? – rjustin