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.

2
  • Where is the userService? Shouldn't you pass in userService instead of forgetService? Also check this answer: Error: ng:areq Commented Apr 21, 2015 at 13:41
  • Can you post your module initialization in the question. mean var myApp = angular.module('myApp'); Commented Apr 21, 2015 at 13:43

1 Answer 1

0

Add this line of code just above controller code

var app = angular.module('myapp', ['forgetService']);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.