angularjs - Why Unknown function "getJalse" in factory Angular JS -
i trying make ajax request php angular js. not getting data have sent php file.
an error unknown function "getjalse" exist in factory
my source:
file app.js:
(function () { var app = angular.module('myapp', ['ngroute']); app.config(function ($routeprovider) { $routeprovider .when('/', { controller: 'contentsctrl', templateurl: 'views/contents.php' }) .when('/jalse/:jalseid', { controller: 'recordsctrl', templateurl: 'views/jalse.php' }) .otherwise({redirectto: '/'}); }); }());
file jalsefactory.js:
(function () { 'use strict'; var jaslefactory = function ($http, $q) { var factory = {}; factory.getjalses = function () { var deferred = $q.defer(); $http({method: 'get', url: 'includes/records.php'}). success(function (data, status, headers, config) { deferred.resolve(data); }). error(function (data, status, headers, config) { deferred.reject(data); }); return deferred.promise; }; return factory; }; jaslefactory.$inject = ['$http', '$q']; angular.module('myapp').factory('jaslefactory', jaslefactory); }());
file recordsctrl.js:
(function () { 'use strict'; var recordsctrl = function ($scope, $routeparams , jaslefactory) { var jalseid = $routeparams.jalseid; $scope.records = jaslefactory.getjalse(); $scope.jalse = null; function init() { (var = 0, len = $scope.records.length; < len; i++) { if ($scope.records[i].contentid == parseint(jalseid)) { $scope.jalse = $scope.records[i]; break; } } } init(); }; recordsctrl.$inject = ['$scope' , '$routeparams' , 'jaslefactory']; angular.module('myapp').controller('recordsctrl', recordsctrl); }());
because factory has getjalses , calling getjalse.
change
factory.getjalses = function ()
to
factory.getjalse = function ()
Comments
Post a Comment