This is the Fiddle I'm using to learn angular js
In short, JS
file being used:
angular.module('ngApp', [])
.service('myownservice', '$q', function ($timeout, $q) {
this.httpcall = function() {
var httpresp = "1818";
//making an http call over here.
return httpresp;
};
this.UpdateSomeData = function () {
var defer = $q.defer();
myownservice.httpcall().then(function(data) {
defer.resolve(data);
});
return defer.promise;
};
})
.controller('ctrl', function ($scope, myownservice) {
$scope.value = UpdateSomeData();
});
html page
:
<div ng-controller="ctrl">{{value}}</div>
But I'm receiving an error like
Argument 'fn' is not a function, got string
.
Any ideas why ?