0

Below is my code in AngularJS. i have created controller but i am getting error :

Error: [ng:areq] Argument 'forgetController' is not a function, got undefined

app.controller("forgetController", function ($scope, forgetService) {
    $scope.OperType = 1;
    // 1  MEANS NEW ENTRY

    GetAllUserRecords();


    function GetAllUserRecords() {
        debugger;
        var promiseGet = userService.GetUserRecords();
        promiseGet.then(function (p1) { $scope.User = p1.data }, function (err) {
            console.log("Error");
        });
    }

    $scope.submit = function () {
        debugger;
        var user = {
            FirstName: $scope.FirstName,
            LastName: $scope.LastName,
            Email: $scope.Email,
            Password: $scope.Password,
            Phone: $scope.Phone,
            Postcode: $scope.Postcode,
            Address: $scope.Address,
            Street: $scope.Street,
            Town: $scope.Town,
            CreateDate: new Date()
        };
        if ($scope.OperType === 1) {
            var promisePost = userService.AddUser(user);
            promisePost.then(function (p1) {
                GetAllUserRecords();
                alert("New Record Inserted");
                $("#addUserTable").css('display', 'none');
                clearClientDetail();
            }, function (err) {
                console.log("Error");
            });
        }
    }

    function clearClientDetail() {
        $("#FirstName").val('');
        $("#LastName").val('');
        $("#Email").val('');
        $("#Password").val('');
        $("#Phone").val('');
        $("#Postcode").val('');
        $("#Address").val('');
        $("#Street").val('');
        $("#Town").val('');
    }
});

i am stuck over here, i google everything but i do not get any result.

Ferrmolina
  • 2,737
  • 2
  • 30
  • 46
Freelencer
  • 31
  • 5
  • Where is the userService? Shouldn't you pass in userService instead of forgetService? Also check this answer: [Error: ng:areq](http://stackoverflow.com/questions/25895235/angularjs-error-ngareq-argument-homecontroller-is-not-a-function-got-und) – Jan Swart Apr 21 '15 at 13:41
  • Can you post your module initialization in the question. mean `var myApp = angular.module('myApp');` – Arulkumar Apr 21 '15 at 13:43

1 Answers1

0

Add this line of code just above controller code

var app = angular.module('myapp', ['forgetService']);